GNOME Bugzilla – Bug 691618
avoid initialising gvfs for local files
Last modified: 2018-02-09 12:33:35 UTC
g_file_new_for_path() is (reasonably) implemented as: return g_vfs_get_file_for_path (g_vfs_get_default (), path); which is just a vcall: return (* class->get_file_for_path) (vfs, path); In gvfs this is: file = g_vfs_get_file_for_path (G_DAEMON_VFS (vfs)->wrapped_vfs, path); file = convert_fuse_path (vfs, file); return file; with vfs->wrapped_vfs = g_vfs_get_local (); In short: we spin up the entire GIOModule/GIOExtensionPoint framework, load a lot of modules, initialise gvfs and call into it just for the purpose of calling back into the 'local' VFS module in GIO. The only case where gvfs does anything at all is if we are giving it a path inside of the fuse root. In that case, it appears to be attempting to convert it back to a native GIO URI. I propose modifying g_file_new_for_path() to short-circuit this insanity and go straight to the local vfs implementation. We can deal with the FUSE case by avoiding the short-circuit for anything that looks like it might be a FUSE path (which we could just determine using the same algorithm gvfs does). We could also possibly modify the for_uri case as well, for file:/// URIs. I suppose it's also possible that we could have a non-gvfs gvfs implementation that does something stranger with local paths...
See also: https://bugzilla.gnome.org/show_bug.cgi?id=665092 https://bugzilla.gnome.org/show_bug.cgi?id=526454
Ouch. The problem is bigger than I thought -- even with my workaround to create a GFile directly using the local vfs I could still end up loading gvfs depending on how I use it? Ugh... In light of that, I'm not sure what I'm proposing here is much help. If the issue in the other bug is really hinging on the back-mapping of FUSE-backed filenames to native URIs (as this bug is as wel) then maybe we should just consider moving the functionality to *detect* these URIs to GLib and only call into gvfs code in the case that one of them pops up...
Can we stop for a moment and clarify why avoiding gvfs is a good thing ? I understand that we want to avoid it in system daemons and commands run as root, but in a full desktop session, there is nothing wrong with using gvfs, imo.
I was just a bit surprised to see dconf-service indirectly loading the dconf client library into itself as a side effect...
yeah, I agree. that is bad
I think we can consider this a duplicate of bug #665092. *** This bug has been marked as a duplicate of bug 665092 ***