From 58f46010b57f10cf0d77944faf32afe875ceec3b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Tue, 14 Aug 2018 09:19:31 +0200 Subject: 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 --- test/testallfilesdeleted.cpp | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'test/testallfilesdeleted.cpp') 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("hasInitialFingerPrint"); -- cgit v1.2.3