From c35b39221e0f65c92cf41252907fc57f6be3baae Mon Sep 17 00:00:00 2001 From: Hannah von Reth <hannah.vonreth@owncloud.com> Date: Thu, 20 May 2021 16:45:52 +0200 Subject: [PATCH] Fix network drive detection We can't rely on the file system detection because Windows is reporting the underlying file system. Fixes: #8272 --- changelog/unreleased/8272 | 5 +++++ src/common/vfs.cpp | 9 +++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changelog/unreleased/8272 diff --git a/changelog/unreleased/8272 b/changelog/unreleased/8272 new file mode 100644 index 00000000000..787818bfeda --- /dev/null +++ b/changelog/unreleased/8272 @@ -0,0 +1,5 @@ +Bugfix: Correctly detect network drives + +We fixed a bug which allowed to use Virtual files on Windows network drives, which is not supported by Windows. + +https://github.com/owncloud/client/issues/8272 diff --git a/src/common/vfs.cpp b/src/common/vfs.cpp index d36caf0937c..b17417ad5c7 100644 --- a/src/common/vfs.cpp +++ b/src/common/vfs.cpp @@ -68,13 +68,18 @@ Result<bool, QString> Vfs::checkAvailability(const QString &path) const auto mode = bestAvailableVfsMode(); #ifdef Q_OS_WIN if (mode == Mode::WindowsCfApi) { - if (QDir(QDir(path).canonicalPath()).isRoot()) { + 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(path); + 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(path);