@@ -330,8 +330,10 @@ private slots:
330
330
QCOMPARE (fakeFolder.currentLocalState (), fakeFolder.currentRemoteState ());
331
331
}
332
332
333
- // Check what happens when we abort during the final MOVE and the
334
- // the final MOVE is short enough for the abort-delay to help
333
+ // Check what happens when we abort during the final MOVE.
334
+ // The move succeeds on the server but as we abort it we won't realize in time.
335
+ // This means that the current sync fails, as it is aborted, but the MOVE was still performed on the server.
336
+ // Resulting in the local state being the same as the remote state.
335
337
void testLateAbortRecoverable ()
336
338
{
337
339
FakeFolder fakeFolder{ FileInfo::A12_B12_C12_S12 () };
@@ -344,18 +346,31 @@ private slots:
344
346
fakeFolder.setServerOverride ([&](QNetworkAccessManager::Operation op, const QNetworkRequest &request, QIODevice *) -> QNetworkReply * {
345
347
if (request.attribute (QNetworkRequest::CustomVerbAttribute).toByteArray () == " MOVE" ) {
346
348
QTimer::singleShot (50ms, &parent, [&]() { fakeFolder.syncEngine ().abort (); });
349
+ // while the response is delayed, the move is performed in the constructor, thus it happens immediately
347
350
return new DelayedReply<FakeChunkMoveReply>(responseDelay, fakeFolder.uploadState (), fakeFolder.remoteModifier (), op, request, &parent);
348
351
}
349
352
return nullptr ;
350
353
});
351
354
352
355
// Test 1: NEW file aborted
353
356
fakeFolder.localModifier ().insert (QStringLiteral (" A/a0" ), size);
357
+ // the sync will be aborted and thus fail
358
+ QVERIFY (!fakeFolder.applyLocalModificationsAndSync ());
359
+ // the move was still performed
360
+ QCOMPARE (fakeFolder.currentLocalState (), fakeFolder.currentRemoteState ());
361
+
362
+ // update the meta data after the aborted sync
354
363
QVERIFY (fakeFolder.applyLocalModificationsAndSync ());
355
364
QCOMPARE (fakeFolder.currentLocalState (), fakeFolder.currentRemoteState ());
356
365
357
366
// Test 2: modified file upload aborted
358
367
fakeFolder.localModifier ().appendByte (QStringLiteral (" A/a0" ));
368
+ // the sync will be aborted and thus fail
369
+ QVERIFY (!fakeFolder.applyLocalModificationsAndSync ());
370
+ // the move was still performed
371
+ QCOMPARE (fakeFolder.currentLocalState (), fakeFolder.currentRemoteState ());
372
+
373
+ // update the meta data after the aborted sync
359
374
QVERIFY (fakeFolder.applyLocalModificationsAndSync ());
360
375
QCOMPARE (fakeFolder.currentLocalState (), fakeFolder.currentRemoteState ());
361
376
}
0 commit comments