]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
on receiving reply of a remote MOVE: always record it
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Thu, 17 Oct 2024 15:58:37 +0000 (17:58 +0200)
committerClaudio Cambra <claudio.cambra@nextcloud.com>
Fri, 18 Oct 2024 02:09:08 +0000 (10:09 +0800)
even if local item has disappeared, record the result of a remote MOVE
when receiving the reply

enable better state tracking when syncing rename or move operations

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/discovery.cpp
src/libsync/propagateremotemove.cpp

index 90f26719e0ad25b526a1c100fdea847e09e33d5d..ee7f7ae3a847ae215766a6cc66d0a4ac07f89f2b 100644 (file)
@@ -1714,7 +1714,7 @@ void ProcessDirectoryJob::processFileFinalize(
         item->_instruction = CSyncEnums::CSYNC_INSTRUCTION_UPDATE_VFS_METADATA;
     }
 
-    if (path._original != path._target && (item->_instruction == CSYNC_INSTRUCTION_UPDATE_METADATA || item->_instruction == CSYNC_INSTRUCTION_NONE)) {
+    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
         // update the database for all items!  See PropagateDirectory::slotSubJobsFinished)
index 6d2c0a229b047fa455859488ae82034edc31ee7e..6a7538748b704354c0cde67c985d8fc630ee591b 100644 (file)
@@ -290,22 +290,17 @@ void PropagateRemoteMove::finalize()
         }
     }
 
-    if (!FileSystem::fileExists(targetFile)) {
-        propagator()->_journal->commit("Remote Rename");
-        done(SyncFileItem::Success, {}, ErrorCategory::NoError);
-        return;
-    }
-
     const auto result = propagator()->updateMetadata(newItem);
-    if (!result) {
+    if (!result && QFileInfo::exists(targetFile)) {
         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(newItem._file), ErrorCategory::GenericError);
         return;
     }
-    if (pinState && *pinState != PinState::Inherited
-        && !vfs->setPinState(newItem._renameTarget, *pinState)) {
+    if (pinState && *pinState != PinState::Inherited &&
+        !vfs->setPinState(newItem._renameTarget, *pinState) &&
+        QFileInfo::exists(targetFile)) {
         done(SyncFileItem::NormalError, tr("Error setting pin state"), ErrorCategory::GenericError);
         return;
     }