From 4774361e8f1b1b85667e34c8b239f85e4566f45a Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 30 Apr 2024 13:31:54 +0200 Subject: [PATCH 1/2] ensure proper VFS metadata when restoring folders when remote move is forbidden, desktop client will move back the folder to its original name in such cases, we were forgetting to set VFS metadata in their proper state (i.e. placeholder in sync) so ensure that when a remote move fails, we still touch VFS metadata when appropriate and handle errors Signed-off-by: Matthieu Gallien --- src/libsync/propagateremotemove.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libsync/propagateremotemove.cpp b/src/libsync/propagateremotemove.cpp index 09cb179d385a9..08222d095eb87 100644 --- a/src/libsync/propagateremotemove.cpp +++ b/src/libsync/propagateremotemove.cpp @@ -216,7 +216,19 @@ void PropagateRemoteMove::slotMoveJobFinished() qCWarning(lcPropagateRemoteMove) << "Could not MOVE file" << filePathOriginal << " to" << filePath << " with error:" << _job->errorString() << " and successfully restored it."; + + auto restoredItem = *_item; + restoredItem._renameTarget = _item->_originalFile; + const auto result = propagator()->updateMetadata(restoredItem); + if (!result) { + done(SyncFileItem::FatalError, tr("Error updating metadata: %1").arg(result.error()), ErrorCategory::GenericError); + return; + } else if (*result == Vfs::ConvertToPlaceholderResult::Locked) { + done(SyncFileItem::SoftError, tr("The file %1 is currently in use").arg(restoredItem._file), ErrorCategory::GenericError); + return; + } } + done(status, _job->errorString(), ErrorCategory::GenericError); return; } From e20ef1c720751d4b470610e132f0f51d4f106b39 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 30 Apr 2024 13:33:58 +0200 Subject: [PATCH 2/2] as a last resort, try to update VFS metadata of folders when discovered when doing local discovery, it is possible that files or folders may be discovered with VFS metadata not up to date (i.e. placeholder file not set in sync) in such case, generate a propagation instruction to set them in sync Signed-off-by: Matthieu Gallien --- src/libsync/discovery.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index d4050ceaa5bf5..57699bee5d77a 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1670,9 +1670,9 @@ void ProcessDirectoryJob::processFileFinalize( } if (_discoveryData->_syncOptions._vfs && - (item->_type == CSyncEnums::ItemTypeFile || item->_type == CSyncEnums::ItemTypeDirectory) && - item->_instruction == CSyncEnums::CSYNC_INSTRUCTION_NONE && - !_discoveryData->_syncOptions._vfs->isPlaceHolderInSync(_discoveryData->_localDir + path._local)) { + (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; }