Fix network drive detection
authorHannah von Reth <hannah.vonreth@owncloud.com>
Thu, 20 May 2021 14:45:52 +0000 (16:45 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Thu, 12 Dec 2024 13:27:48 +0000 (13:27 +0000)
We can't rely on the file system detection because Windows is reporting the underlying file system.

Fixes: #8272
src/common/vfs.cpp

index e887937f066dcc285cbfa09cb303260386f3279a..84df80c76ec41f591f01c7c95b4c8cdac459a2cc 100644 (file)
@@ -70,10 +70,18 @@ Result<bool, QString> Vfs::checkAvailability(const QString &path)
     const auto mode = bestAvailableVfsMode();
 #ifdef Q_OS_WIN
     if (mode == Mode::WindowsCfApi) {
-        const auto fs = FileSystem::fileSystemForPath(path);
+        const auto info = QFileInfo(path);
+        if (QDir(info.canonicalPath()).isRoot()) {
+            return tr("The Virtual filesystem feature does not support a drive as sync root");
+        }
+        const auto fs = FileSystem::fileSystemForPath(info.absoluteFilePath());
         if (fs != QLatin1String("NTFS")) {
             return tr("The Virtual filesystem feature requires a NTFS file system, %1 is using %2").arg(path, fs);
         }
+        const auto type = GetDriveTypeW(reinterpret_cast<const wchar_t *>(QDir::toNativeSeparators(info.absoluteFilePath().mid(0, 3)).utf16()));
+        if (type == DRIVE_REMOTE) {
+            return tr("The Virtual filesystem feature is not supported on network drives");
+        }
     }
 #else
     Q_UNUSED(mode)