diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2018-08-14 10:19:31 +0300 |
---|---|---|
committer | Olivier Goffart <olivier@woboq.com> | 2018-08-15 10:34:19 +0300 |
commit | 58f46010b57f10cf0d77944faf32afe875ceec3b (patch) | |
tree | b45de0b4f0a05af88d5bf7b68cd6385912a592d5 /test/testallfilesdeleted.cpp | |
parent | 3dcf2479adcc1bf802088933e1547f7e64b0ce21 (diff) |
SyncEngine: Fix the "direction" of the "all file delted" message when the server is reset
Using the direction of the "first" item is not enough as it might be a directory
which is a UPDATE_META_DATA, or there can have been a few changes locally as well.
As reported on https://github.com/owncloud/client/issues/6317#issuecomment-412163113
Diffstat (limited to 'test/testallfilesdeleted.cpp')
-rw-r--r-- | test/testallfilesdeleted.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/test/testallfilesdeleted.cpp b/test/testallfilesdeleted.cpp index a2f6f4851..e0dbbdd44 100644 --- a/test/testallfilesdeleted.cpp +++ b/test/testallfilesdeleted.cpp @@ -152,6 +152,38 @@ private slots: QCOMPARE(fakeFolder.currentRemoteState(), expectedState); } + void testResetServer() + { + FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()}; + + int aboutToRemoveAllFilesCalled = 0; + QObject::connect(&fakeFolder.syncEngine(), &SyncEngine::aboutToRemoveAllFiles, + [&](SyncFileItem::Direction dir, bool *cancel) { + QCOMPARE(aboutToRemoveAllFilesCalled, 0); + aboutToRemoveAllFilesCalled++; + QCOMPARE(dir, SyncFileItem::Down); + *cancel = false; + }); + + // Some small changes + fakeFolder.localModifier().mkdir("Q"); + fakeFolder.localModifier().insert("Q/q1"); + fakeFolder.localModifier().appendByte("B/b1"); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(aboutToRemoveAllFilesCalled, 0); + + // Do some change localy + fakeFolder.localModifier().appendByte("A/a1"); + + // reset the server. + fakeFolder.remoteModifier() = FileInfo::A12_B12_C12_S12(); + + // Now, aboutToRemoveAllFiles with down as a direction + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(aboutToRemoveAllFilesCalled, 1); + + } + void testDataFingetPrint_data() { QTest::addColumn<bool>("hasInitialFingerPrint"); |