From 3a20ea871b9faa67f879168690ee597118dda15f Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Mon, 20 Jan 2025 17:05:56 +0100 Subject: [PATCH 1/3] handle LNK virtual files only when VFS mode is not off should ensure lnk widnows shortcut files are not mistakenly handled as virtual files Signed-off-by: Matthieu Gallien --- src/libsync/discovery.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index ad23815a4451a..e2305a81ee114 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1662,14 +1662,14 @@ void ProcessDirectoryJob::processFileFinalize( } } - if (_discoveryData->_syncOptions._vfs && + if (_discoveryData->_syncOptions._vfs && _discoveryData->_syncOptions._vfs->mode() != OCC::Vfs::Off && (item->_type == CSyncEnums::ItemTypeFile || item->_type == CSyncEnums::ItemTypeDirectory) && item->_instruction == CSyncEnums::CSYNC_INSTRUCTION_NONE && !_discoveryData->_syncOptions._vfs->isPlaceHolderInSync(_discoveryData->_localDir + path._local)) { item->_instruction = CSyncEnums::CSYNC_INSTRUCTION_UPDATE_VFS_METADATA; } - if (_discoveryData->_syncOptions._vfs && + if (_discoveryData->_syncOptions._vfs && _discoveryData->_syncOptions._vfs->mode() != OCC::Vfs::Off && (item->_type == CSyncEnums::ItemTypeFile || item->_type == CSyncEnums::ItemTypeDirectory) && item->_instruction == CSyncEnums::CSYNC_INSTRUCTION_NONE && FileSystem::isLnkFile((_discoveryData->_localDir + path._local)) && From b8f853a135cc4f1c974260c8fecb567652334e8c Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Mon, 20 Jan 2025 17:10:09 +0100 Subject: [PATCH 2/3] add an assert to ensure we do not use virtual file types with no VFS if VFS mode is off, we should nto be using any virtual file types Signed-off-by: Matthieu Gallien --- src/libsync/discovery.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index e2305a81ee114..3b9785a62b32b 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1712,6 +1712,16 @@ void ProcessDirectoryJob::processFileFinalize( } else { recurse = false; } + + if (!(item->isDirectory() || + (!_discoveryData->_syncOptions._vfs || _discoveryData->_syncOptions._vfs->mode() != OCC::Vfs::Off) || + item->_type != CSyncEnums::ItemTypeVirtualFile || + item->_type != CSyncEnums::ItemTypeVirtualFileDownload || + item->_type != CSyncEnums::ItemTypeVirtualFileDehydration)) { + qCCritical(lcDisco()) << "wong item type for" << item->_file << item->_type; + Q_ASSERT(false); + } + if (recurse) { auto job = new ProcessDirectoryJob(path, item, recurseQueryLocal, recurseQueryServer, _lastSyncTimestamp, this); From 7c3ac180d7841273cad5706b1303ae0c1b270f7f Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 21 Jan 2025 15:35:57 +0100 Subject: [PATCH 3/3] update metadata when a file item has wrong type in DB should help fixing the type of windows shortcuts in DB that were wrongly set as virtual files Signed-off-by: Matthieu Gallien --- src/libsync/discovery.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 3b9785a62b32b..831b85e334bb7 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1679,6 +1679,18 @@ void ProcessDirectoryJob::processFileFinalize( item->_type = CSyncEnums::ItemTypeVirtualFileDehydration; } + if (item->_instruction != CSyncEnums::CSYNC_INSTRUCTION_NONE && + !item->isDirectory() && + _discoveryData->_syncOptions._vfs && + _discoveryData->_syncOptions._vfs->mode() == OCC::Vfs::Off && + (item->_type == CSyncEnums::ItemTypeVirtualFile || + item->_type == CSyncEnums::ItemTypeVirtualFileDownload || + item->_type == CSyncEnums::ItemTypeVirtualFileDehydration)) { + item->_instruction = CSyncEnums::CSYNC_INSTRUCTION_UPDATE_METADATA; + item->_direction = SyncFileItem::Down; + item->_type = CSyncEnums::ItemTypeFile; + } + if (path._original != path._target && (item->_instruction == CSYNC_INSTRUCTION_UPDATE_VFS_METADATA || item->_instruction == CSYNC_INSTRUCTION_UPDATE_METADATA || item->_instruction == CSYNC_INSTRUCTION_NONE)) { ASSERT(_dirItem && _dirItem->_instruction == CSYNC_INSTRUCTION_RENAME); // This is because otherwise subitems are not updated! (ideally renaming a directory could