Skip to content

Commit

Permalink
Iteration for tests.
Browse files Browse the repository at this point in the history
Signed-off-by: alex-z <[email protected]>
  • Loading branch information
allexzander committed Nov 13, 2023
1 parent badbf13 commit 2a6a7eb
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/libsync/propagateremotemove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,8 @@ void PropagateRemoteMove::slotMoveJobFinished()
auto newItem = SyncFileItem::fromSyncJournalFileRecord(rec);
newItem->_originalFile = QString(newItem->_file).replace(_item->_renameTarget, _item->_originalFile);
newItem->_renameTarget = newItem->_file;
newItem->_instruction = CSYNC_INSTRUCTION_RENAME;
newItem->_direction = SyncFileItem::Up;
const auto fsPath = propagator()->fullLocalPath(newItem->_renameTarget);
quint64 inode = rec._inode;
if (!FileSystem::getInode(fsPath, &inode)) {
Expand All @@ -257,6 +259,39 @@ void PropagateRemoteMove::slotMoveJobFinished()
return;
}
}
auto &vfs = propagator()->syncOptions()._vfs;
// TODO: vfs->pinState(_item->_originalFile); does not make sense as item is already gone from original location, do we need this?
auto pinState = vfs->pinState(newItem->_originalFile);
const auto targetFile = propagator()->fullLocalPath(newItem->_renameTarget);

if (QFileInfo::exists(targetFile)) {
// Delete old db data.
if (!propagator()->_journal->deleteFileRecord(_item->_originalFile)) {
qCWarning(lcPropagateRemoteMove) << "could not delete file from local DB" << _item->_originalFile;
done(SyncFileItem::NormalError,
tr("Could not delete file record %1 from local DB").arg(_item->_originalFile),
ErrorCategory::GenericError);
return;
}
// TODO: vfs->setPinState(_item->_originalFile, PinState::Inherited) will always fail as item is already gone from original location, do we
// need this?
if (!vfs->setPinState(_item->_originalFile, PinState::Inherited)) {
qCWarning(lcPropagateRemoteMove) << "Could not set pin state of" << _item->_originalFile << "to inherited";
}
}
const auto result = propagator()->updateMetadata(*newItem);
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(newItem->_file), ErrorCategory::GenericError);
return;
}
if (pinState && *pinState != PinState::Inherited && !vfs->setPinState(newItem->_renameTarget, *pinState)) {
done(SyncFileItem::NormalError, tr("Error setting pin state"), ErrorCategory::GenericError);
return;
}

})) {
qCWarning(lcPropagateRemoteMove) << "Could not update inode for moved files in" << _item->_renameTarget;
}
Expand Down

0 comments on commit 2a6a7eb

Please sign in to comment.