From cb38bb2b5ea10d56124ba66dfba1da949043fc9b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Wed, 9 Oct 2019 09:31:00 +0200 Subject: [PATCH] Fix Upload of large (> 2GiB) files Issue #7506 This is a regression introduced by the delta sync feature (as the chunk offset changed from being the chunk number to be the byte offset, it needs to be a qint64 now) --- test/testchunkingng.cpp | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/test/testchunkingng.cpp b/test/testchunkingng.cpp index 94bc66620..8a49bb538 100644 --- a/test/testchunkingng.cpp +++ b/test/testchunkingng.cpp @@ -13,14 +13,14 @@ using namespace OCC; /* Upload a 1/3 of a file of given size. * fakeFolder needs to be synchronized */ -static void partialUpload(FakeFolder &fakeFolder, const QString &name, int size) +static void partialUpload(FakeFolder &fakeFolder, const QString &name, qint64 size) { QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); QCOMPARE(fakeFolder.uploadState().children.count(), 0); // The state should be clean fakeFolder.localModifier().insert(name, size); // Abort when the upload is at 1/3 - int sizeWhenAbort = -1; + qint64 sizeWhenAbort = -1; auto con = QObject::connect(&fakeFolder.syncEngine(), &SyncEngine::transmissionProgress, [&](const ProgressInfo &progress) { if (progress.completedSize() > (progress.totalSize() /3 )) { @@ -591,6 +591,36 @@ private slots: QVERIFY(fakeFolder.syncOnce()); QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); } + + // Test uploading large files (2.5GiB) + void testVeryBigFiles() { + FakeFolder fakeFolder{FileInfo::A12_B12_C12_S12()}; + fakeFolder.syncEngine().account()->setCapabilities({ { "dav", QVariantMap{ {"chunking", "1.0"} } } }); + const qint64 size = 2.5 * 1024 * 1024 * 1024; // 2.5 GiB + + // Partial upload of big files + partialUpload(fakeFolder, "A/a0", size); + QCOMPARE(fakeFolder.uploadState().children.count(), 1); + auto chunkingId = fakeFolder.uploadState().children.first().name; + + // Now resume + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + QCOMPARE(fakeFolder.currentRemoteState().find("A/a0")->size, size); + + // The same chunk id was re-used + QCOMPARE(fakeFolder.uploadState().children.count(), 1); + QCOMPARE(fakeFolder.uploadState().children.first().name, chunkingId); + + + // Upload another file again, this time without interruption + fakeFolder.localModifier().appendByte("A/a0"); + QVERIFY(fakeFolder.syncOnce()); + QCOMPARE(fakeFolder.currentLocalState(), fakeFolder.currentRemoteState()); + QCOMPARE(fakeFolder.currentRemoteState().find("A/a0")->size, size + 1); + } + + }; QTEST_GUILESS_MAIN(TestChunkingNG) -- 2.30.2