diff --git a/src/libsync/propagatorjobs.cpp b/src/libsync/propagatorjobs.cpp index 9749f5a1d..82167f5b9 100644 --- a/src/libsync/propagatorjobs.cpp +++ b/src/libsync/propagatorjobs.cpp @@ -224,10 +224,10 @@ void PropagateLocalRename::start() auto &vfs = propagator()->syncOptions()._vfs; const auto previousNameInDb = propagator()->adjustRenamedPath(_item->_file); - const auto existingFile = propagator()->fullLocalPath(propagator()->adjustRenamedPath(_item->_file)); + const auto existingFile = propagator()->fullLocalPath(previousNameInDb); const auto targetFile = propagator()->fullLocalPath(_item->_renameTarget); - const auto fileAlreadyMoved = !QFileInfo::exists(propagator()->fullLocalPath(_item->_originalFile)); + const auto fileAlreadyMoved = !QFileInfo::exists(propagator()->fullLocalPath(_item->_originalFile)) && QFileInfo::exists(existingFile); auto pinState = OCC::PinState::Unspecified; if (!fileAlreadyMoved) { auto pinStateResult = vfs->pinState(propagator()->adjustRenamedPath(_item->_file)); @@ -239,6 +239,7 @@ void PropagateLocalRename::start() // if the file is a file underneath a moved dir, the _item->file is equal // to _item->renameTarget and the file is not moved as a result. qCDebug(lcPropagateLocalRename) << _item->_file << _item->_renameTarget << _item->_originalFile << previousNameInDb << (fileAlreadyMoved ? "original file has already moved" : "original file is still there"); + Q_ASSERT(QFileInfo::exists(propagator()->fullLocalPath(_item->_originalFile)) || QFileInfo::exists(existingFile)); if (_item->_file != _item->_renameTarget) { propagator()->reportProgress(*_item, 0); qCDebug(lcPropagateLocalRename) << "MOVE " << existingFile << " => " << targetFile; diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp index 04f29f8be..8ad198155 100644 --- a/test/testsyncmove.cpp +++ b/test/testsyncmove.cpp @@ -84,6 +84,12 @@ class TestSyncMove : public QObject Q_OBJECT private slots: + void initTestCase() + { + Logger::instance()->setLogFlush(true); + Logger::instance()->setLogDebug(true); + } + void testMoveCustomRemoteRoot() { FileInfo subFolder(QStringLiteral("AS"), { { QStringLiteral("f1"), 4 } }); @@ -140,7 +146,22 @@ private slots: void testSelectiveSyncMovedFolder() { // issue #5224 - FakeFolder fakeFolder{ FileInfo{ QString(), { FileInfo{ QStringLiteral("parentFolder"), { FileInfo{ QStringLiteral("subFolderA"), { { QStringLiteral("fileA.txt"), 400 } } }, FileInfo{ QStringLiteral("subFolderB"), { { QStringLiteral("fileB.txt"), 400 } } } } } } } }; + FakeFolder fakeFolder{ + FileInfo{QString(), { + FileInfo{QStringLiteral("parentFolder"), { + FileInfo{QStringLiteral("subFolderA"), { + {QStringLiteral("fileA.txt"), 400} + } + }, + FileInfo{QStringLiteral("subFolderB"), { + {QStringLiteral("fileB.txt"), 400} + } + } + } + } + } + } + }; QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); auto expectedServerState = fakeFolder.currentRemoteState();