Opening files from google drive with Nautilus and GNOME Online Accounts

Hi

I’ve recently made the full transition from using windows to only using Ubuntu. As a heavy user of G-Drive one of the first things I did was add my google account to GNOME online accounts. However every time I try and open a file on my Google Drive from Nautilus (file manager) it doesn’t work. Say I’m trying to open one of my old .doc files Libreoffice simply says the file is locked by another user. This also happens with my Password safe and a number of other applications.

I’ve spent the last couple of days researching the inner working of GVfs… but I seem no closer to a solution. So far my research seems to suggest trying to use my Google Drive via GNOME online accounts is almost useless, but surely this must be wrong.

I’m also a little confused how the front-end and back-end of GVfs work/interact

Please help, anything much appreciated!

Sam

What happens if you copy the .doc files to your local disk and open them in LibreOffice ?

Specifics would help.

E.g.

App1 fails with error message “abc …”
App2 fails with error message “xyz …”

etc.

Hi

Sorry I’ll try to be more specific and focus on one problem and error. Let’s start with libreoffice.

I open my google drive in Nautilus with GNOME online accounts. Double click on a old .doc file, say it is My.doc, and get a “Document in use” dialogue box which says “This file has been locked by another user”. If I ask for more details it says something like “Document Name: 0B-VDXPLHIXrd25KMUE0Wktpa1E User Name: Unknown User”

Screenshot from 2023-08-15 11-37-05

Clearly the document name is incorrect; the document is really called “My.doc” or similar. This happens on all the documents. I can copy them to my computer and they open fine. The only solutions I can find on google are people switching off document locking which seems inelegant.

Sam

The garbled document name is fine. Refer - Google Drive filenames are garbled when accessing from shell (#402) · Issues · GNOME / gvfs · GitLab

  1. Can you create a .doc file locally in your system with LibreOffice, copy it to google-drive and open it. Do you still see the same issue ?

  2. If yes to [1], can you run the following command as “root” in a terminal ?

    # journalctl -f
    

    Now open the My.doc from google-drive in nautilus, and see if there are any gvfs / apparmor errors in journalctl.

  3. List the OS / package versions ( gvfs / libreoffice etc ) being used.

Hi

I had come to understand that the garbled name was a property of the working of the Google Drive API.

  1. New .doc created with LibreOffice → transferted to my GDrive → exactly the same behavour

  2. Ok there is something funky happening on the DBUS:

I’m not sure what the atk-bridge is or the GTL+ module is, I thought they were to do with graphics, however from what I understand of the working of the GVfs I can see that the DBUS errors is something to do with it… although I’m not familar with DBUS so I don’t understand what I’m looking at yet. I see nothing below that would be private so here’s the read out of the journal:

Aug 15 14:19:11 MetalBeast systemd[73197]: Started snap.libreoffice.writer.99206047-8160-4fe3-a999-9a6988c4aac9.scope.
Aug 15 14:19:14 MetalBeast soffice.bin[170296]: Not loading module "atk-bridge": The functionality is provided by GTK natively. Please try to not load it.
Aug 15 14:19:14 MetalBeast soffice.bin[170296]: GTK+ module /snap/libreoffice/285/gnome-platform/usr/lib/gtk-2.0/modules/libcanberra-gtk-module.so cannot be loaded.
                                                GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported.
Aug 15 14:19:14 MetalBeast soffice.bin[170296]: Failed to load module "canberra-gtk-module"
Aug 15 14:19:14 MetalBeast soffice.bin[170296]: GTK+ module /snap/libreoffice/285/gnome-platform/usr/lib/gtk-2.0/modules/libcanberra-gtk-module.so cannot be loaded.
                                                GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported.
Aug 15 14:19:14 MetalBeast soffice.bin[170296]: Failed to load module "canberra-gtk-module"
Aug 15 14:19:14 MetalBeast dbus-daemon[73221]: apparmor="DENIED" operation="dbus_method_call"  bus="session" path="/org/libreoffice" interface="org.freedesktop.DBus.Properties" member="GetAll" name=":1.43" mask="receive" pid=170296 label="snap.libreoffice.writer" peer_pid=73518 peer_label="unconfined"
Aug 15 14:19:15 MetalBeast audit[170296]: SECCOMP auid=1000 uid=1000 gid=1000 ses=112 subj=snap.libreoffice.writer pid=170296 comm="configmgrWriter" exe="/snap/libreoffice/285/lib/libreoffice/program/soffice.bin" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7fba52c1dc1b code=0x50000
Aug 15 14:19:15 MetalBeast kernel: audit: type=1326 audit(1692105555.495:576): auid=1000 uid=1000 gid=1000 ses=112 subj=snap.libreoffice.writer pid=170296 comm="configmgrWriter" exe="/snap/libreoffice/285/lib/libreoffice/program/soffice.bin" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7fba52c1dc1b code=0x50000
Aug 15 14:19:16 MetalBeast dbus-daemon[73221]: apparmor="DENIED" operation="dbus_method_call"  bus="session" path="/org/libreoffice" interface="org.freedesktop.DBus.Properties" member="GetAll" name=":1.43" mask="receive" pid=170296 label="snap.libreoffice.writer" peer_pid=73518 peer_label="unconfined"
Aug 15 14:19:17 MetalBeast audit[170296]: SECCOMP auid=1000 uid=1000 gid=1000 ses=112 subj=snap.libreoffice.writer pid=170296 comm="configmgrWriter" exe="/snap/libreoffice/285/lib/libreoffice/program/soffice.bin" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7fba52c1dc1b code=0x50000
Aug 15 14:19:17 MetalBeast kernel: audit: type=1326 audit(1692105557.883:577): auid=1000 uid=1000 gid=1000 ses=112 subj=snap.libreoffice.writer pid=170296 comm="configmgrWriter" exe="/snap/libreoffice/285/lib/libreoffice/program/soffice.bin" sig=0 arch=c000003e syscall=92 compat=0 ip=0x7fba52c1dc1b code=0x50000
Aug 15 14:20:46 MetalBeast gnome-shell[73518]: JS ERROR: TypeError: this.actor is null
                                               _syncEnabled@resource:///org/gnome/shell/ui/windowManager.js:138:25
                                               onStopped@resource:///org/gnome/shell/ui/windowManager.js:150:35
                                               _makeEaseCallback/<@resource:///org/gnome/shell/ui/environment.js:151:22
                                               _easeActorProperty/<@resource:///org/gnome/shell/ui/environment.js:317:60
                                               _destroyWindowDone@resource:///org/gnome/shell/ui/windowManager.js:1596:21
                                               onStopped@resource:///org/gnome/shell/ui/windowManager.js:1564:39
                                               _makeEaseCallback/<@resource:///org/gnome/shell/ui/environment.js:151:22
                                               _easeActor/<@resource:///org/gnome/shell/ui/environment.js:240:64
Aug 15 14:20:46 MetalBeast systemd[73197]: snap.libreoffice.writer.99206047-8160-4fe3-a999-9a6988c4aac9.scope: Consumed 4.237s CPU time.

3:
Ubuntu 22.04.3 LTS
GNOME 42.9
LibreOffice 7.5.5.2

not sure how to get teh gvfs verstion, I’ve tried gvfs --version and gvfsd --version in a terminal and am told thats not a command.

Thanks for your help

It appears like you’re running libreoffice snap version. There seems to be some issue in the snap apparmor profiles for libreoffice. You should get in touch with the Ubuntu snap team to resolve this issue.

Installing the libreoffice system version ( .deb ) should work fine.

Also in future, if you’re facing issues with any app, and if that’s a snap version, please do check if the same issue exists in the system installed version before reporting it here.

Thanks!

Hi Sid

Thanks very very much, that does seem to have solved the Office problem.

Following your suggestions, I uninstalled the snap version and instead installed LibreOffice from the .deb files downloaded from the official LibreOffice website. Everything seems to be functioning as expected now.

I’m going to spend a bit more time trying to understand both the journal output and finding out what AppArmor is.

I think my installation came with the snap version of Libreoffice so I was using everything out of the box, one of the reasons I thought everything should just work. I will drop a message to the Snap team to let them know it’s not working in the stock installation.

I’m still having problems with Password Safe. I’m not sure if programs (in general) should be able to use my GDrive like any other file system. I.e. this could be a problem that Password Safe isn’t implementing the necessary file management.

The software opens files “read only” just fine from GDrive. But Password Safe uses a file locking mechanism of writing a file with the same name as the open file with .plk postfix. When I try and open a file fully I get a similar error “Could not lock file, open read-only. File or Path not found”:

Screenshot from 2023-08-17 10-16-53

There’s very little outputted to the Jornal while I’m trying to open the file:

Aug 17 10:17:56 MetalBeast systemd[1]: Started Hostname Service.
Aug 17 10:18:25 MetalBeast gnome-shell[73518]: JS ERROR: TypeError: this.actor is null
                                               _syncEnabled@resource:///org/gnome/shell/ui/windowManager.js:138:25
                                               onStopped@resource:///org/gnome/shell/ui/windowManager.js:150:35
                                               _makeEaseCallback/<@resource:///org/gnome/shell/ui/environment.js:151:22
                                               _easeActorProperty/<@resource:///org/gnome/shell/ui/environment.js:317:60
                                               _destroyWindowDone@resource:///org/gnome/shell/ui/windowManager.js:1596:21
                                               onStopped@resource:///org/gnome/shell/ui/windowManager.js:1584:39
                                               _makeEaseCallback/<@resource:///org/gnome/shell/ui/environment.js:151:22
                                               _easeActor/<@resource:///org/gnome/shell/ui/environment.js:240:64
Aug 17 10:18:26 MetalBeast systemd[1]: systemd-hostnamed.service: Deactivated successfully.

This is probably something I need to report to password safe to do something to make the file locking work as I’m guessing it can’t write a .plk file due to the garbled file name?

Thanks again

Sam

This is a GNOME support forum. We don’t offer support for software outside of GNOME ( unless there is evidence that the issue is caused by GNOME libraries ( Gtk / GLib etc ), which is not the case here, as Password Safe doesn’t use any of GNOME libraries, other than the fact that it opens a path create by Gvfs ).

So, please report future issues to the respective projects first.

Having said that, a quick look suggests “PasswordSafe” cannot properly handle paths created by Gvfs.

E.g. GetLockFileName() in [src/os/unix/file.cpp]

You can contact “PasswordSafe” support.

Cheers!

Hi Sid

This is a GNOME support forum. We don’t offer support for software outside of GNOME ( unless there is evidence that the issue is caused by GNOME libraries ( Gtk / GLib etc ), which is not the case here, as Password Safe doesn’t use any of GNOME libraries, other than the fact that it opens a path create by Gvfs ).

My question was really “Can a program use the paths created by Gvfs to access GDrive in a standard way” and my understand is “No you do have to handle them diffrently” which I guess would be easiest done by using Gio.

As a stop gap solution “google-drive-ocamlfuse” seems to offer an alternative, although it was not handeling the meta data correctly for PasswordSafe for some reason, but again I’ll drop them a bug report.

Thanks for all your help

Sam

“Password Safe” works on the garbled filename, so it doesn’t work in this case.

GIO can demangle the original filename from the garbled filename ( based on the file metadata ). That’s how the original filename is displayed in nautilus. I am not sure if this demangling can be done outside of GIO ( via glibc / linux system calls etc ), but I guess it should be possible.

Hi Sid

would it be possible to write a program that could warp an application like “Password safe” intercepting the system calls and converting them to the relevant GIO commands?

If you can’t intercept the system calls I guess it would be easy to write a program to copy a file from the Gdrive to a local folder, open the program (like Password safe) to manipulate it and then copy it back on completion. Although I think I’ve basically reinvented google-drive-ocamlfuse but just cut down for a single file.

I think the Google drive app on windows just kept a local copy of my Gdrive on my computer and updated as necessary.

The fact that the receiving program has to look at the metadata to figure out what’s going on really does limit the usefulness of GNOME online accounts. I’m also having problems attaching files from my GDrive to emails, specifically with Outlook which I’m force to use for work.

The problem with google drive and file name based locking is that in google drive a file name does not uniquely identify a file. You can have a directory with a file named passwords and right next to it another file named passwords:

google drive screenshot

Just so it’s clear.

GetLockFileName() fn mentioned in above comment didn’t have any locking issues. It just had path string manipulation issue, where the ".com" from "gmail.com" interfered with its file extension detection logic.

But even if that got fixed, it will likely not work due to there being no way of creating a file with a specific name, because representing a google drive mount requires using the IDs as file names due to the google drive “feature” of having multiple files with the same name. And I don’t think it is possible to influence the IDs from the client side.

Hi both

Blockquote GetLockFileName() fn mentioned in above comment didn’t have any locking issues. It just had path string manipulation issue, where the ".com" from "gmail.com" interfered with its file extension detection logic.

Thanks for the heads up, I’ll pass that along. Also if that is problem I might be able to fix it, however I normally do C not C++

I’m having a new problem that I can’t attach files from my google drive in Outlook web mail using either Chrome or Firefox. I can’t see anything in the log and don’t get any error message, simply try and attach a file from my drive via the standard dialogue box, click open and nothing happens.

I’m afraid I’m still behind on my research, Google drive must have some form of file locking?

How is this problem sorted out in Windows? Can you just add some meta data of your own to make unique IDs? (i.e. scan the folder and add (1), (2) to the end of repeated file names as your own tag)

Sam

I’m not a Windows user, but I don’t think Windows mounts Google Drive. I think it instead syncs the files or rather a subset of the files, because I doubt Windows supports multiple files with the same name either.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.