Merge pull request #5224 from nextcloud/bugfix/caseCashConflictsShouldNotTerminateSync

Bugfix/case cash conflicts should not terminate sync
This commit is contained in:
Matthieu Gallien 2022-11-30 13:44:44 +01:00 committed by GitHub
commit ba6537d710
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 5 deletions

View file

@ -1333,6 +1333,7 @@ void PropagateRootDirectory::slotSubJobsFinished(SyncFileItem::Status status)
if (status != SyncFileItem::Success if (status != SyncFileItem::Success
&& status != SyncFileItem::Restoration && status != SyncFileItem::Restoration
&& status != SyncFileItem::BlacklistedError && status != SyncFileItem::BlacklistedError
&& status != SyncFileItem::FileNameClash
&& status != SyncFileItem::Conflict) { && status != SyncFileItem::Conflict) {
if (_state != Finished) { if (_state != Finished) {
// Synchronously abort // Synchronously abort
@ -1355,12 +1356,12 @@ void PropagateRootDirectory::slotSubJobsFinished(SyncFileItem::Status status)
case SyncFileItem::FileLocked: case SyncFileItem::FileLocked:
case SyncFileItem::Restoration: case SyncFileItem::Restoration:
case SyncFileItem::FileNameInvalid: case SyncFileItem::FileNameInvalid:
case SyncFileItem::FileNameClash:
case SyncFileItem::DetailError: case SyncFileItem::DetailError:
case SyncFileItem::Success: case SyncFileItem::Success:
break; break;
case SyncFileItem::FileNameClash:
case SyncFileItem::BlacklistedError: case SyncFileItem::BlacklistedError:
_errorStatus = SyncFileItem::BlacklistedError; _errorStatus = status;
break; break;
} }
} }

View file

@ -102,7 +102,7 @@ void PropagateLocalRemove::start()
qCInfo(lcPropagateLocalRemove) << "Going to delete:" << filename; qCInfo(lcPropagateLocalRemove) << "Going to delete:" << filename;
if (propagator()->localFileNameClash(_item->_file)) { if (propagator()->localFileNameClash(_item->_file)) {
done(SyncFileItem::NormalError, tr("Could not remove %1 because of a local file name clash").arg(QDir::toNativeSeparators(filename))); done(SyncFileItem::FileNameClash, tr("Could not remove %1 because of a local file name clash").arg(QDir::toNativeSeparators(filename)));
return; return;
} }
@ -178,7 +178,7 @@ void PropagateLocalMkdir::startLocalMkdir()
if (Utility::fsCasePreserving() && propagator()->localFileNameClash(_item->_file)) { if (Utility::fsCasePreserving() && propagator()->localFileNameClash(_item->_file)) {
qCWarning(lcPropagateLocalMkdir) << "New folder to create locally already exists with different case:" << _item->_file; qCWarning(lcPropagateLocalMkdir) << "New folder to create locally already exists with different case:" << _item->_file;
done(SyncFileItem::NormalError, tr("Attention, possible case sensitivity clash with %1").arg(newDirStr)); done(SyncFileItem::FileNameClash, tr("Attention, possible case sensitivity clash with %1").arg(newDirStr));
return; return;
} }
emit propagator()->touchedFile(newDirStr); emit propagator()->touchedFile(newDirStr);
@ -250,7 +250,7 @@ void PropagateLocalRename::start()
// Fixme: the file that is the reason for the clash could be named here, // Fixme: the file that is the reason for the clash could be named here,
// it would have to come out the localFileNameClash function // it would have to come out the localFileNameClash function
done(SyncFileItem::NormalError, done(SyncFileItem::FileNameClash,
tr("File %1 cannot be renamed to %2 because of a local file name clash") tr("File %1 cannot be renamed to %2 because of a local file name clash")
.arg(QDir::toNativeSeparators(_item->_file), QDir::toNativeSeparators(_item->_renameTarget))); .arg(QDir::toNativeSeparators(_item->_file), QDir::toNativeSeparators(_item->_renameTarget)));
return; return;

View file

@ -1282,6 +1282,27 @@ private slots:
QVERIFY(fileThirdSync); QVERIFY(fileThirdSync);
QCOMPARE(fileThirdSync->lastModified.toSecsSinceEpoch(), CURRENT_MTIME); QCOMPARE(fileThirdSync->lastModified.toSecsSinceEpoch(), CURRENT_MTIME);
} }
void testFolderRemovalWithCaseClash()
{
FakeFolder fakeFolder{ FileInfo{} };
fakeFolder.remoteModifier().mkdir("A");
fakeFolder.remoteModifier().mkdir("toDelete");
fakeFolder.remoteModifier().insert("A/file");
QVERIFY(fakeFolder.syncOnce());
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
fakeFolder.remoteModifier().insert("A/FILE");
QVERIFY(fakeFolder.syncOnce());
fakeFolder.remoteModifier().mkdir("a");
fakeFolder.remoteModifier().remove("toDelete");
QVERIFY(fakeFolder.syncOnce());
auto folderA = fakeFolder.currentLocalState().find("toDelete");
QCOMPARE(folderA, nullptr);
}
}; };
QTEST_GUILESS_MAIN(TestSyncEngine) QTEST_GUILESS_MAIN(TestSyncEngine)