Skip to content

Commit

Permalink
Merge pull request #5224 from nextcloud/bugfix/caseCashConflictsShoul…
Browse files Browse the repository at this point in the history
…dNotTerminateSync

Bugfix/case cash conflicts should not terminate sync
  • Loading branch information
mgallien authored Nov 30, 2022
2 parents 4b5186d + 1725055 commit ba6537d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/libsync/owncloudpropagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1333,6 +1333,7 @@ void PropagateRootDirectory::slotSubJobsFinished(SyncFileItem::Status status)
if (status != SyncFileItem::Success
&& status != SyncFileItem::Restoration
&& status != SyncFileItem::BlacklistedError
&& status != SyncFileItem::FileNameClash
&& status != SyncFileItem::Conflict) {
if (_state != Finished) {
// Synchronously abort
Expand All @@ -1355,12 +1356,12 @@ void PropagateRootDirectory::slotSubJobsFinished(SyncFileItem::Status status)
case SyncFileItem::FileLocked:
case SyncFileItem::Restoration:
case SyncFileItem::FileNameInvalid:
case SyncFileItem::FileNameClash:
case SyncFileItem::DetailError:
case SyncFileItem::Success:
break;
case SyncFileItem::FileNameClash:
case SyncFileItem::BlacklistedError:
_errorStatus = SyncFileItem::BlacklistedError;
_errorStatus = status;
break;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/libsync/propagatorjobs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ void PropagateLocalRemove::start()
qCInfo(lcPropagateLocalRemove) << "Going to delete:" << filename;

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;
}

Expand Down Expand Up @@ -178,7 +178,7 @@ void PropagateLocalMkdir::startLocalMkdir()

if (Utility::fsCasePreserving() && propagator()->localFileNameClash(_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;
}
emit propagator()->touchedFile(newDirStr);
Expand Down Expand Up @@ -250,7 +250,7 @@ void PropagateLocalRename::start()

// Fixme: the file that is the reason for the clash could be named here,
// 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")
.arg(QDir::toNativeSeparators(_item->_file), QDir::toNativeSeparators(_item->_renameTarget)));
return;
Expand Down
21 changes: 21 additions & 0 deletions test/testsyncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,27 @@ private slots:
QVERIFY(fileThirdSync);
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)
Expand Down

0 comments on commit ba6537d

Please sign in to comment.