From 55ee3f440b9877c02b696371dbce29e40e37fca9 Mon Sep 17 00:00:00 2001 From: Christian Kamm Date: Wed, 24 Jul 2019 16:07:28 +0200 Subject: [PATCH] Vfs: Remove old db record when dehydrating via rename For #7338 --- src/libsync/discovery.cpp | 12 ++++++++---- test/testsyncvirtualfiles.cpp | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 97a5e9aca..8472b819d 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -720,8 +720,10 @@ void ProcessDirectoryJob::processFileAnalyzeLocalInfo( if (dbEntry._modtime == localEntry.modtime && dbEntry._fileSize == localEntry.size) { qCInfo(lcDisco) << "Base file was renamed to virtual file:" << item->_file; item->_direction = SyncFileItem::Down; - item->_instruction = CSYNC_INSTRUCTION_NEW; - item->_type = ItemTypeVirtualFile; + item->_instruction = CSYNC_INSTRUCTION_SYNC; + item->_type = ItemTypeVirtualFileDehydration; + addVirtualFileSuffix(item->_file); + item->_renameTarget = item->_file; } else { qCInfo(lcDisco) << "Virtual file with non-virtual db entry, ignoring:" << item->_file; item->_instruction = CSYNC_INSTRUCTION_IGNORE; @@ -1058,8 +1060,10 @@ void ProcessDirectoryJob::processFileFinalize( } if (item->_type == ItemTypeVirtualFileDehydration && item->_instruction == CSYNC_INSTRUCTION_SYNC) { - item->_renameTarget = item->_file; - addVirtualFileSuffix(item->_renameTarget); + if (item->_renameTarget.isEmpty()) { + item->_renameTarget = item->_file; + addVirtualFileSuffix(item->_renameTarget); + } } } diff --git a/test/testsyncvirtualfiles.cpp b/test/testsyncvirtualfiles.cpp index 323c52b36..9f2477049 100644 --- a/test/testsyncvirtualfiles.cpp +++ b/test/testsyncvirtualfiles.cpp @@ -402,6 +402,7 @@ private slots: QVERIFY(itemInstruction(completeSpy, "A/b4m" DVSUFFIX, CSYNC_INSTRUCTION_NEW)); QVERIFY(itemInstruction(completeSpy, "A/b4", CSYNC_INSTRUCTION_REMOVE)); QCOMPARE(dbRecord(fakeFolder, "A/a1")._type, ItemTypeFile); + QVERIFY(!dbRecord(fakeFolder, "A/a1" DVSUFFIX).isValid()); QCOMPARE(dbRecord(fakeFolder, "A/a2")._type, ItemTypeFile); QVERIFY(!dbRecord(fakeFolder, "A/a3").isValid()); QCOMPARE(dbRecord(fakeFolder, "A/a4m")._type, ItemTypeFile); @@ -409,6 +410,7 @@ private slots: QCOMPARE(dbRecord(fakeFolder, "A/a6")._type, ItemTypeFile); QCOMPARE(dbRecord(fakeFolder, "A/a7")._type, ItemTypeFile); QCOMPARE(dbRecord(fakeFolder, "A/b1")._type, ItemTypeFile); + QVERIFY(!dbRecord(fakeFolder, "A/b1" DVSUFFIX).isValid()); QCOMPARE(dbRecord(fakeFolder, "A/b2")._type, ItemTypeFile); QVERIFY(!dbRecord(fakeFolder, "A/b3").isValid()); QCOMPARE(dbRecord(fakeFolder, "A/b4m" DVSUFFIX)._type, ItemTypeVirtualFile); @@ -612,8 +614,9 @@ private slots: QVERIFY(!fakeFolder.currentLocalState().find("A/a1")); QVERIFY(fakeFolder.currentLocalState().find("A/a1" DVSUFFIX)); QVERIFY(fakeFolder.currentRemoteState().find("A/a1")); - QVERIFY(itemInstruction(completeSpy, "A/a1" DVSUFFIX, CSYNC_INSTRUCTION_NEW)); + QVERIFY(itemInstruction(completeSpy, "A/a1" DVSUFFIX, CSYNC_INSTRUCTION_SYNC)); QCOMPARE(dbRecord(fakeFolder, "A/a1" DVSUFFIX)._type, ItemTypeVirtualFile); + QVERIFY(!dbRecord(fakeFolder, "A/a1").isValid()); QVERIFY(!fakeFolder.currentLocalState().find("A/a2")); QVERIFY(!fakeFolder.currentLocalState().find("A/a2" DVSUFFIX)); -- 2.30.2