Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vfs: Remove old db record when dehydrating via rename #7342

Merged
merged 1 commit into from
Jul 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,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;
Expand Down Expand Up @@ -1050,8 +1052,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);
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion test/testsyncvirtualfiles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,15 @@ 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);
QCOMPARE(dbRecord(fakeFolder, "A/a5")._type, ItemTypeFile);
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);
Expand Down Expand Up @@ -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));
Expand Down