SocketAPI: fix status after a failure to move

Issue #7759
This commit is contained in:
Olivier Goffart 2020-03-25 11:37:03 +01:00 committed by Kevin Ottens
parent 734e49765d
commit 317d3735d7
No known key found for this signature in database
GPG key ID: 074BBBCB8DECC9E2
2 changed files with 49 additions and 5 deletions

View file

@ -230,10 +230,10 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector &items)
_dirtyPaths.remove(item->destination());
if (hasErrorStatus(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusError;
_syncProblems[item->destination()] = SyncFileStatus::StatusError;
invalidateParentPaths(item->destination());
} else if (hasExcludedStatus(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusExcluded;
_syncProblems[item->destination()] = SyncFileStatus::StatusExcluded;
}
SharedFlag sharedFlag = item->_remotePerm.hasPermission(RemotePermissions::IsShared) ? Shared : NotShared;
@ -274,12 +274,12 @@ void SyncFileStatusTracker::slotItemCompleted(const SyncFileItemPtr &item)
qCDebug(lcStatusTracker) << "Item completed" << item->destination() << item->_status << item->_instruction;
if (hasErrorStatus(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusError;
_syncProblems[item->destination()] = SyncFileStatus::StatusError;
invalidateParentPaths(item->destination());
} else if (hasExcludedStatus(*item)) {
_syncProblems[item->_file] = SyncFileStatus::StatusExcluded;
_syncProblems[item->destination()] = SyncFileStatus::StatusExcluded;
} else {
_syncProblems.erase(item->_file);
_syncProblems.erase(item->destination());
}
SharedFlag sharedFlag = item->_remotePerm.hasPermission(RemotePermissions::IsShared) ? Shared : NotShared;

View file

@ -465,6 +465,50 @@ private slots:
QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState());
}
void renameError() {
FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()};
fakeFolder.serverErrorPaths().append("A/a1");
fakeFolder.localModifier().rename("A/a1", "A/a1m");
fakeFolder.localModifier().rename("B/b1", "B/b1m");
StatusPushSpy statusSpy(fakeFolder.syncEngine());
fakeFolder.scheduleSync();
fakeFolder.execUntilBeforePropagation();
verifyThatPushMatchesPull(fakeFolder, statusSpy);
QCOMPARE(statusSpy.statusOf("A/a1m"), SyncFileStatus(SyncFileStatus::StatusSync));
QCOMPARE(statusSpy.statusOf("A/a1"), statusSpy.statusOf("A/a1notexist"));
QCOMPARE(statusSpy.statusOf("A"), SyncFileStatus(SyncFileStatus::StatusSync));
QCOMPARE(statusSpy.statusOf(""), SyncFileStatus(SyncFileStatus::StatusSync));
QCOMPARE(statusSpy.statusOf("B"), SyncFileStatus(SyncFileStatus::StatusSync));
QCOMPARE(statusSpy.statusOf("B/b1m"), SyncFileStatus(SyncFileStatus::StatusSync));
fakeFolder.execUntilFinished();
verifyThatPushMatchesPull(fakeFolder, statusSpy);
QCOMPARE(statusSpy.statusOf("A/a1m"), SyncFileStatus(SyncFileStatus::StatusError));
QCOMPARE(statusSpy.statusOf("A/a1"), statusSpy.statusOf("A/a1notexist"));
QCOMPARE(statusSpy.statusOf("A"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf(""), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf("B"), SyncFileStatus(SyncFileStatus::StatusUpToDate));
QCOMPARE(statusSpy.statusOf("B/b1m"), SyncFileStatus(SyncFileStatus::StatusUpToDate));
statusSpy.clear();
QVERIFY(!fakeFolder.syncOnce());
verifyThatPushMatchesPull(fakeFolder, statusSpy);
statusSpy.clear();
QVERIFY(!fakeFolder.syncOnce());
verifyThatPushMatchesPull(fakeFolder, statusSpy);
QCOMPARE(statusSpy.statusOf("A/a1m"), SyncFileStatus(SyncFileStatus::StatusError));
QCOMPARE(statusSpy.statusOf("A/a1"), statusSpy.statusOf("A/a1notexist"));
QCOMPARE(statusSpy.statusOf("A"), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf(""), SyncFileStatus(SyncFileStatus::StatusWarning));
QCOMPARE(statusSpy.statusOf("B"), SyncFileStatus(SyncFileStatus::StatusNone));
QCOMPARE(statusSpy.statusOf("B/b1m"), SyncFileStatus(SyncFileStatus::StatusNone));
statusSpy.clear();
}
};
QTEST_GUILESS_MAIN(TestSyncFileStatusTracker)