diff --git a/test/testsyncmove.cpp b/test/testsyncmove.cpp index 8ad19815524ca..f4926722f681f 100644 --- a/test/testsyncmove.cpp +++ b/test/testsyncmove.cpp @@ -1063,6 +1063,66 @@ private slots: QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); } + + void testRenameSameFileInMultiplePaths() + { + FakeFolder fakeFolder{FileInfo{}}; + + fakeFolder.remoteModifier().mkdir("FolderA"); + fakeFolder.remoteModifier().mkdir("FolderA/folderParent"); + fakeFolder.remoteModifier().mkdir("FolderB"); + fakeFolder.remoteModifier().mkdir("FolderB/folderChild"); + fakeFolder.remoteModifier().insert("FolderB/folderChild/FileA.txt"); + fakeFolder.remoteModifier().mkdir("FolderC"); + + const auto folderParentFileInfo = fakeFolder.remoteModifier().find("FolderA/folderParent"); + const auto folderParentSharedFolderFileId = folderParentFileInfo->fileId; + const auto folderParentSharedFolderEtag = folderParentFileInfo->etag; + const auto folderChildFileInfo = fakeFolder.remoteModifier().find("FolderB/folderChild"); + const auto folderChildInFolderAFolderFileId = folderChildFileInfo->fileId; + const auto folderChildInFolderAEtag = folderChildFileInfo->etag; + const auto fileAFileInfo = fakeFolder.remoteModifier().find("FolderB/folderChild/FileA.txt"); + const auto fileAInFolderAFolderFileId = fileAFileInfo->fileId; + const auto fileAInFolderAEtag = fileAFileInfo->etag; + + auto folderCFileInfo = fakeFolder.remoteModifier().find("FolderC"); + folderCFileInfo->fileId = folderParentSharedFolderFileId; + folderCFileInfo->etag = folderParentSharedFolderEtag; + + QVERIFY(fakeFolder.syncOnce()); + + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + + fakeFolder.remoteModifier().remove("FolderB/folderChild"); + fakeFolder.remoteModifier().mkdir("FolderA/folderParent/folderChild"); + fakeFolder.remoteModifier().insert("FolderA/folderParent/folderChild/FileA.txt"); + fakeFolder.remoteModifier().mkdir("FolderC/folderChild"); + fakeFolder.remoteModifier().insert("FolderC/folderChild/FileA.txt"); + + auto folderChildInFolderParentFileInfo = fakeFolder.remoteModifier().find("FolderA/folderParent/folderChild"); + folderChildInFolderParentFileInfo->fileId = folderChildInFolderAFolderFileId; + folderChildInFolderParentFileInfo->etag = folderChildInFolderAEtag; + + auto fileAInFolderParentFileInfo = fakeFolder.remoteModifier().find("FolderA/folderParent/folderChild/FileA.txt"); + fileAInFolderParentFileInfo->fileId = fileAInFolderAFolderFileId; + fileAInFolderParentFileInfo->etag = fileAInFolderAEtag; + + auto folderChildInFolderCFileInfo = fakeFolder.remoteModifier().find("FolderC/folderChild"); + folderChildInFolderCFileInfo->fileId = folderChildInFolderAFolderFileId; + folderChildInFolderCFileInfo->etag = folderChildInFolderAEtag; + + auto fileAInFolderCFileInfo = fakeFolder.remoteModifier().find("FolderC/folderChild/FileA.txt"); + fileAInFolderCFileInfo->fileId = fileAInFolderAFolderFileId; + fileAInFolderCFileInfo->etag = fileAInFolderAEtag; + + fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::FilesystemOnly); + QVERIFY(fakeFolder.syncOnce()); + + fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::FilesystemOnly); + QVERIFY(fakeFolder.syncOnce()); + + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + } }; QTEST_GUILESS_MAIN(TestSyncMove)