From 4375f7d86ab76669ecddf2ad6bea203826de5425 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 e842f82540808..800e9b4203e85 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 463114e30435dc34321d73d953bca96ae458bed3 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 800e9b4203e85..ec4beb1234b61 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 0b5b8aadb907e15cd02dad12729a19044217ca69 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 6d7a36c9404b6..408d85623eaf6 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);