void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status)
{
if (!_item->isEmpty() && status == SyncFileItem::Success) {
- if (!_item->_renameTarget.isEmpty()) {
- if (_item->_instruction == CSYNC_INSTRUCTION_RENAME
- && _item->_originalFile != _item->_renameTarget) {
- // Remove the stale entries from the database.
- propagator()->_journal->deleteFileRecord(_item->_originalFile, true);
- }
-
- _item->_file = _item->_renameTarget;
+ // If a directory is renamed, recursively delete any stale items
+ // that may still exist below the old path.
+ if (_item->_instruction == CSYNC_INSTRUCTION_RENAME
+ && _item->_originalFile != _item->_renameTarget) {
+ propagator()->_journal->deleteFileRecord(_item->_originalFile, true);
}
// For new directories we always want to update the etag once
qCDebug(lcPropagateDownload) << "dehydrating file" << _item->_file;
vfs->dehydratePlaceholder(*_item);
propagator()->_journal->deleteFileRecord(_item->_originalFile);
- // NOTE: This is only done because other rename-like ops also adjust _file, even though
- // updateMetadata() will store at destination() anyway. Doing this may not be necessary
- // but maybe it has an effect on reporting (destination() and moves aren't handled
- // consistently everywhere)
- _item->_file = _item->destination();
updateMetadata(false);
return;
}
propagator()->_journal->getFileRecord(_item->_originalFile, &oldRecord);
propagator()->_journal->deleteFileRecord(_item->_originalFile);
- // store the rename file name in the item.
const auto oldFile = _item->_file;
- _item->_file = _item->_renameTarget;
if (!_item->isDirectory()) { // Directories are saved at the end
SyncFileItem newItem(*_item);
QCOMPARE(counter.nDELETE, 0);
QVERIFY(itemSuccessfulMove(completeSpy, "A/a1m"));
QVERIFY(itemSuccessfulMove(completeSpy, "B/b1m"));
+ QCOMPARE(findItem(completeSpy, "A/a1m")->_file, QStringLiteral("A/a1"));
+ QCOMPARE(findItem(completeSpy, "A/a1m")->_renameTarget, QStringLiteral("A/a1m"));
+ QCOMPARE(findItem(completeSpy, "B/b1m")->_file, QStringLiteral("B/b1"));
+ QCOMPARE(findItem(completeSpy, "B/b1m")->_renameTarget, QStringLiteral("B/b1m"));
}
// Touch+Move on same side
QCOMPARE(counter.nDELETE, 0);
QVERIFY(itemSuccessfulMove(completeSpy, "AM"));
QVERIFY(itemSuccessfulMove(completeSpy, "BM"));
+ QCOMPARE(findItem(completeSpy, "AM")->_file, QStringLiteral("A"));
+ QCOMPARE(findItem(completeSpy, "AM")->_renameTarget, QStringLiteral("AM"));
+ QCOMPARE(findItem(completeSpy, "BM")->_file, QStringLiteral("B"));
+ QCOMPARE(findItem(completeSpy, "BM")->_renameTarget, QStringLiteral("BM"));
}
// Folder move with contents touched on the same side
QVERIFY(hasDehydratedDbEntries("A/a1"));
QVERIFY(itemInstruction(completeSpy, "A/a1.nextcloud", CSYNC_INSTRUCTION_SYNC));
QCOMPARE(findItem(completeSpy, "A/a1.nextcloud")->_type, ItemTypeVirtualFileDehydration);
+ QCOMPARE(findItem(completeSpy, "A/a1.nextcloud")->_file, QStringLiteral("A/a1"));
+ QCOMPARE(findItem(completeSpy, "A/a1.nextcloud")->_renameTarget, QStringLiteral("A/a1.nextcloud"));
QVERIFY(isDehydrated("A/a2"));
QVERIFY(hasDehydratedDbEntries("A/a2"));
QVERIFY(itemInstruction(completeSpy, "A/a2.nextcloud", CSYNC_INSTRUCTION_SYNC));