Skip to content

Commit

Permalink
on receiving reply of a remote MOVE: always record it
Browse files Browse the repository at this point in the history
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 <[email protected]>

[skip ci]
  • Loading branch information
mgallien authored and backportbot[bot] committed Oct 18, 2024
1 parent 0e441d5 commit d93a5d6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,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)
Expand Down
7 changes: 4 additions & 3 deletions src/libsync/propagateremotemove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,15 +296,16 @@ void PropagateRemoteMove::finalize()
}

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;
}
Expand Down

0 comments on commit d93a5d6

Please sign in to comment.