From: Kevin Ottens Date: Mon, 4 Jan 2021 15:13:29 +0000 (+0100) Subject: Add the plumbing for a new extended attributes backend X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~424^2~3 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=a89b483773ba1e54d4025ef3f30a5e24149d2c3c;p=nextcloud-desktop.git Add the plumbing for a new extended attributes backend Ideally this will end up being the backend we use for both Linux and macOS but that will require work with desktop environments on the Linux side and to reverse engineering at least on xattr value on macOS. Signed-off-by: Kevin Ottens --- diff --git a/src/common/vfs.cpp b/src/common/vfs.cpp index b1bdb5324..e9cf977d9 100644 --- a/src/common/vfs.cpp +++ b/src/common/vfs.cpp @@ -53,6 +53,8 @@ QString Vfs::modeToString(Mode mode) return QStringLiteral("suffix"); case WindowsCfApi: return QStringLiteral("wincfapi"); + case XAttr: + return QStringLiteral("xattr"); } return QStringLiteral("off"); } @@ -145,6 +147,8 @@ static QString modeToPluginName(Vfs::Mode mode) return QStringLiteral("suffix"); if (mode == Vfs::WindowsCfApi) return QStringLiteral("win"); + if (mode == Vfs::XAttr) + return QStringLiteral("xattr"); return QString(); } @@ -171,9 +175,32 @@ Vfs::Mode OCC::bestAvailableVfsMode() { if (isVfsPluginAvailable(Vfs::WindowsCfApi)) { return Vfs::WindowsCfApi; - } else if (isVfsPluginAvailable(Vfs::WithSuffix)) { + } + + if (isVfsPluginAvailable(Vfs::WithSuffix)) { return Vfs::WithSuffix; } + + // For now the "suffix" backend has still precedence over the "xattr" backend. + // Ultimately the order of those ifs will change when xattr will be more mature. + // But what does "more mature" means here? + // + // * On Mac when it properly reads and writes com.apple.LaunchServices.OpenWith + // This will require reverse engineering to see what they stuff in there. Maybe a good + // starting point: + // https://eclecticlight.co/2017/12/20/xattr-com-apple-launchservices-openwith-sets-a-custom-app-to-open-a-file/ + // + // * On Linux when our user.nextcloud.hydrate_exec is adopted by at least KDE and Gnome + // the "user.nextcloud" prefix might turn into "user.xdg" in the process since it would + // be best to have a freedesktop.org spec for it. + // When that time comes, it might still require detecting at runtime if that's indeed + // supported in the user session or even per sync folder (in case user would pick a folder + // which wouldn't support xattr for some reason) + + if (isVfsPluginAvailable(Vfs::XAttr)) { + return Vfs::XAttr; + } + return Vfs::Off; } diff --git a/src/common/vfs.h b/src/common/vfs.h index 77501a67e..bb9ef6192 100644 --- a/src/common/vfs.h +++ b/src/common/vfs.h @@ -95,6 +95,7 @@ public: Off, WithSuffix, WindowsCfApi, + XAttr, }; Q_ENUM(Mode) static QString modeToString(Mode mode);