The generalization of the cloud storage comes with a lot of promises and I really like the possibility to access to my personnal files from everywhere: web, laptop, personnal computer, ... With my Android smartphone, it's a native feature. With my Ubuntu the feature is recent and there are serious limitations.
Mounting google drive with Nautilus
Years ago I was using rclone to access to my google drive files. Rclone have really nice mount feature. But I finally give up because there is no simple way to automate the login. You always have difficulties to renew the token. Here come the nautilus feature that allow you to set oneline account. It's available from the gnome-control-center.
Once configured you can access to your google drive files. But I quicky realized that a lot of
applications didn't work if the files are located on the drive. Gnumeric, gedit are
working but keepassxc or vim
doesn't work at all. With keepassxc it sometimes results in data corruption! With vim
the file is correctly displayed but saving the file failed. Even if the nobackup
option,
some strange errors appeared.
Under the hood
Nautilus is using a dedicated library named gio that provide all the features to access to remote drives like google. The official gio description tells provide an API that is so good that developers prefer it over raw POSIX calls! I was a little bit surprized when I read this :-). The gio command allows us to manipulate the filesystem from the command line using the gio primitives. Comparing the output of gio's commands to the standard unix commands (ls, cat) is meaningfull. We can understand how gio transform I/O to display the content in nautilus.
$ ls
17lXzXGnhfA89w39PitPdtblkoOW8t8rA 1HnbYPHAwbchlu1pCMnRS-qxRQtfs4ULO 1LJ9W3ZzmfVMyzE09abGOIswXwdjwI8x2
$ gio list -d
mytext2.txt
kpwd
simpsons
$ gio cat mytext2.txt
toto
titi
tata
tutu
Why some applications work and other don't work
- If the application use the standard POSIX functions like
open
,read
,write
and manipulate files through plain-old file descriptors it will not work. - If the application use the gio library and the gio abstractions like
GFile
,GFileInfo
,GInputStream
it will work. When usingopen
directly on the file exposed by gio mount it will break the file because open is not aware that it is a network share. And some attributes like 'standard::display-name' are lost when performing IOs. From Nautilus, if you open a file with an application that don't use gio you could corrupt or lost the file!
the future?
I can't imagine that all applications will use gio in the future. Gio is intended for Gnome application not for all the application.
- Is it possible to have a native support for Google Drive in the future? I mean that you can access without any additionnal library like gio or KIO.
- Is it possible for gio to intercept POSIX calls and transform them into GIO call?
Not sure because this is complex. But it could be a better user experience.