From 3f4936171205aee9f56119e4127982d1bf8be314 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 3 Jan 2025 15:32:38 +0100 Subject: [PATCH 1/3] force dehydratation of lnk files when vfs metadata are wrong Close #7696 Signed-off-by: Matthieu Gallien --- src/libsync/discovery.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 927a248da67b0..833e3ffa01774 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1672,7 +1672,8 @@ void ProcessDirectoryJob::processFileFinalize( if (_discoveryData->_syncOptions._vfs && (item->_type == CSyncEnums::ItemTypeFile || item->_type == CSyncEnums::ItemTypeDirectory) && item->_instruction == CSyncEnums::CSYNC_INSTRUCTION_NONE && - FileSystem::isLnkFile((_discoveryData->_localDir + path._local))) { + FileSystem::isLnkFile((_discoveryData->_localDir + path._local)) && + !_discoveryData->_syncOptions._vfs->isPlaceHolderInSync(_discoveryData->_localDir + path._local)) { item->_instruction = CSyncEnums::CSYNC_INSTRUCTION_SYNC; item->_direction = SyncFileItem::Down; item->_type = CSyncEnums::ItemTypeVirtualFileDehydration; From f12f66f4e64441cb72af110eec6942784352e2d7 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 3 Jan 2025 15:33:50 +0100 Subject: [PATCH 2/3] fix code style Signed-off-by: Matthieu Gallien --- src/libsync/discovery.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 833e3ffa01774..ad23815a4451a 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -2205,20 +2205,24 @@ void ProcessDirectoryJob::setupDbPinStateActions(SyncJournalFileRecord &record) { // Only suffix-vfs uses the db for pin states. // Other plugins will set localEntry._type according to the file's pin state. - if (!isVfsWithSuffix()) + if (!isVfsWithSuffix()) { return; + } auto pin = _discoveryData->_statedb->internalPinStates().rawForPath(record._path); - if (!pin || *pin == PinState::Inherited) + if (!pin || *pin == PinState::Inherited) { pin = _pinState; + } // OnlineOnly hydrated files want to be dehydrated - if (record._type == ItemTypeFile && *pin == PinState::OnlineOnly) + if (record._type == ItemTypeFile && *pin == PinState::OnlineOnly) { record._type = ItemTypeVirtualFileDehydration; + } // AlwaysLocal dehydrated files want to be hydrated - if (record._type == ItemTypeVirtualFile && *pin == PinState::AlwaysLocal) + if (record._type == ItemTypeVirtualFile && *pin == PinState::AlwaysLocal) { record._type = ItemTypeVirtualFileDownload; + } } } From 6f8a40f73e8f965da5a6e8771fdbfd96cf3f8537 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 3 Jan 2025 15:34:07 +0100 Subject: [PATCH 3/3] prevent implicit hydration when checking PIN state to enable move to trash, we check availability of a folder recursively that will trigger implicit hydration of its content we will now prevent moving to trash for VFS CfApi native VFS on Windows will fix teh bug and probably be much more robust and reliable Signed-off-by: Matthieu Gallien --- src/libsync/propagatorjobs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 6d1bb1b6fddcf..99e69719dac23 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -118,7 +118,7 @@ void PropagateLocalRemove::start() QString removeError; const auto availability = propagator()->syncOptions()._vfs->availability(_item->_file, Vfs::AvailabilityRecursivity::RecursiveAvailability); - if (_moveToTrash && (!availability || (*availability != VfsItemAvailability::AllDehydrated && *availability != VfsItemAvailability::OnlineOnly && *availability != VfsItemAvailability::Mixed))) { + if (_moveToTrash && propagator()->syncOptions()._vfs->mode() != OCC::Vfs::WindowsCfApi) { if ((QDir(filename).exists() || FileSystem::fileExists(filename)) && !FileSystem::moveToTrash(filename, &removeError)) { done(SyncFileItem::NormalError, removeError, ErrorCategory::GenericError);