Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync: Respect maximum chunk size provided in server capabilities #7772

Merged
merged 12 commits into from
Jan 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*

Check notice on line 1 in src/gui/folder.cpp

View workflow job for this annotation

GitHub Actions / build

Run clang-format on src/gui/folder.cpp

File src/gui/folder.cpp does not conform to Custom style guidelines. (lines 1156, 1157)
* Copyright (C) by Duncan Mac-Vicar P. <[email protected]>
* Copyright (C) by Daniel Molkentin <[email protected]>
* Copyright (C) by Klaas Freitag <[email protected]>
Expand All @@ -13,7 +13,7 @@
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*/
#include "common/syncjournaldb.h"

Check failure on line 16 in src/gui/folder.cpp

View workflow job for this annotation

GitHub Actions / build

src/gui/folder.cpp:16:10 [clang-diagnostic-error]

'common/syncjournaldb.h' file not found
#include "config.h"

#include "account.h"
Expand Down Expand Up @@ -1144,20 +1144,31 @@
{
SyncOptions opt;
ConfigFile cfgFile;
const auto account = _accountState->account();

auto newFolderLimit = cfgFile.newBigFolderSizeLimit();
opt._newBigFolderSizeLimit = newFolderLimit.first ? newFolderLimit.second * 1000LL * 1000LL : -1; // convert from MB to B
opt._confirmExternalStorage = cfgFile.confirmExternalStorage();
opt._moveFilesToTrash = cfgFile.moveToTrash();
opt._vfs = _vfs;
opt._parallelNetworkJobs = _accountState->account()->isHttp2Supported() ? 20 : 6;

const auto capsMaxConcurrentChunkUploads = account->capabilities().maxConcurrentChunkUploads();
opt._parallelNetworkJobs = capsMaxConcurrentChunkUploads > 0
? capsMaxConcurrentChunkUploads
: account->isHttp2Supported() ? 20 : 6;

// Chunk V2: Size of chunks must be between 5MB and 5GB, except for the last chunk which can be smaller
opt.setMinChunkSize(cfgFile.minChunkSize());
opt.setMaxChunkSize(cfgFile.maxChunkSize());
opt._initialChunkSize = ::qBound(opt.minChunkSize(), cfgFile.chunkSize(), opt.maxChunkSize());
opt._targetChunkUploadDuration = cfgFile.targetChunkUploadDuration();
const auto cfgMinChunkSize = cfgFile.minChunkSize();
opt.setMinChunkSize(cfgMinChunkSize);

if (const auto capsMaxChunkSize = account->capabilities().maxChunkSize(); capsMaxChunkSize) {
opt.setMaxChunkSize(capsMaxChunkSize);
opt._initialChunkSize = capsMaxChunkSize;
} else {
const auto cfgMaxChunkSize = cfgFile.maxChunkSize();
opt.setMaxChunkSize(cfgMaxChunkSize);
opt._initialChunkSize = ::qBound(cfgMinChunkSize, cfgFile.chunkSize(), cfgMaxChunkSize);
}
opt.fillFromEnvironmentVariables();
opt.verifyChunkSizes();

Expand Down
10 changes: 10 additions & 0 deletions src/libsync/capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,16 @@ bool Capabilities::chunkingNg() const
return _capabilities["dav"].toMap()["chunking"].toByteArray() >= "1.0";
}

qint64 Capabilities::maxChunkSize() const
{
return _capabilities["files"].toMap()["chunked_upload"].toMap()["max_size"].toLongLong();
}

int Capabilities::maxConcurrentChunkUploads() const
{
return _capabilities["files"].toMap()["chunked_upload"].toMap()["max_parallel_count"].toInt();
}

bool Capabilities::bulkUpload() const
{
return _capabilities["dav"].toMap()["bulkupload"].toByteArray() >= "1.0";
Expand Down
2 changes: 2 additions & 0 deletions src/libsync/capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#ifndef CAPABILITIES_H
#define CAPABILITIES_H

#include "owncloudlib.h"

Check failure on line 19 in src/libsync/capabilities.h

View workflow job for this annotation

GitHub Actions / build

src/libsync/capabilities.h:19:10 [clang-diagnostic-error]

'owncloudlib.h' file not found

#include <QVariantMap>
#include <QStringList>
Expand Down Expand Up @@ -64,6 +64,8 @@
[[nodiscard]] bool shareResharing() const;
[[nodiscard]] int shareDefaultPermissions() const;
[[nodiscard]] bool chunkingNg() const;
[[nodiscard]] qint64 maxChunkSize() const;
[[nodiscard]] int maxConcurrentChunkUploads() const;
[[nodiscard]] bool bulkUpload() const;
[[nodiscard]] bool filesLockAvailable() const;
[[nodiscard]] bool filesLockTypeAvailable() const;
Expand Down
Loading