diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2019-10-09 10:31:00 +0300 |
---|---|---|
committer | Olivier Goffart <olivier@woboq.com> | 2019-10-09 14:55:06 +0300 |
commit | 06e3a98e8dccb3d036f571b681d4c6ca334f6bb9 (patch) | |
tree | 1287738ccb845580782d568509770c836ef96b07 /test | |
parent | b8c6133827226dcb57de1655c8f11bf8af156536 (diff) |
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)
Diffstat (limited to 'test')
-rw-r--r-- | test/syncenginetestutils.h | 4 | ||||
-rw-r--r-- | test/testchunkingng.cpp | 34 |
2 files changed, 34 insertions, 4 deletions
diff --git a/test/syncenginetestutils.h b/test/syncenginetestutils.h index 1007bbc5a..eb757edd5 100644 --- a/test/syncenginetestutils.h +++ b/test/syncenginetestutils.h @@ -770,7 +770,7 @@ public: Q_ASSERT(sourceFolder); Q_ASSERT(sourceFolder->isDir); int count = 0; - int size = 0; + qlonglong size = 0; qlonglong prev = 0; char payload = '\0'; @@ -798,7 +798,7 @@ public: // For zsync, get the size from the header, and allow no-chunk uploads (shrinking files) if (zsync) { - size = request.rawHeader("OC-Total-File-Length").toInt(); + size = request.rawHeader("OC-Total-File-Length").toLongLong(); if (count == 0) { if (auto info = remoteRootFileInfo.find(fileName)) payload = info->contentChar; diff --git a/test/testchunkingng.cpp b/test/testchunkingng.cpp index 91f659900..348c0df0d 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 )) { @@ -589,6 +589,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) |