mirror of
https://github.com/nextcloud/desktop.git
synced 2024-11-25 22:46:04 +03:00
owncloudcmd: Use env vars for chunk sizes #7078
Moves a bunch of env var reading from Folder into SyncOptions.
This commit is contained in:
parent
10e02b0031
commit
ebaa98fa7a
4 changed files with 39 additions and 37 deletions
|
@ -505,6 +505,11 @@ restart_sync:
|
|||
selectiveSyncFixup(&db, selectiveSyncList);
|
||||
}
|
||||
|
||||
SyncOptions opt;
|
||||
opt.fillFromEnvironmentVariables();
|
||||
opt.verifyChunkSizes();
|
||||
opt._deltaSyncEnabled = false;
|
||||
opt._deltaSyncMinFileSize = false;
|
||||
SyncEngine engine(account, options.source_dir, folder, &db);
|
||||
engine.setIgnoreHiddenFiles(options.ignoreHiddenFiles);
|
||||
engine.setNetworkLimits(options.uplimit, options.downlimit);
|
||||
|
|
|
@ -874,42 +874,18 @@ void Folder::setSyncOptions()
|
|||
opt._confirmExternalStorage = cfgFile.confirmExternalStorage();
|
||||
opt._moveFilesToTrash = cfgFile.moveToTrash();
|
||||
opt._vfs = _vfs;
|
||||
opt._parallelNetworkJobs = _accountState->account()->isHttp2Supported() ? 20 : 6;
|
||||
|
||||
QByteArray chunkSizeEnv = qgetenv("OWNCLOUD_CHUNK_SIZE");
|
||||
if (!chunkSizeEnv.isEmpty()) {
|
||||
opt._initialChunkSize = chunkSizeEnv.toUInt();
|
||||
} else {
|
||||
opt._initialChunkSize = cfgFile.chunkSize();
|
||||
}
|
||||
QByteArray minChunkSizeEnv = qgetenv("OWNCLOUD_MIN_CHUNK_SIZE");
|
||||
if (!minChunkSizeEnv.isEmpty()) {
|
||||
opt._minChunkSize = minChunkSizeEnv.toUInt();
|
||||
} else {
|
||||
opt._minChunkSize = cfgFile.minChunkSize();
|
||||
}
|
||||
QByteArray maxChunkSizeEnv = qgetenv("OWNCLOUD_MAX_CHUNK_SIZE");
|
||||
if (!maxChunkSizeEnv.isEmpty()) {
|
||||
opt._maxChunkSize = maxChunkSizeEnv.toUInt();
|
||||
} else {
|
||||
opt._maxChunkSize = cfgFile.maxChunkSize();
|
||||
}
|
||||
opt._initialChunkSize = cfgFile.chunkSize();
|
||||
opt._minChunkSize = cfgFile.minChunkSize();
|
||||
opt._maxChunkSize = cfgFile.maxChunkSize();
|
||||
opt._targetChunkUploadDuration = cfgFile.targetChunkUploadDuration();
|
||||
|
||||
int maxParallel = qgetenv("OWNCLOUD_MAX_PARALLEL").toUInt();
|
||||
opt._parallelNetworkJobs = maxParallel ? maxParallel : _accountState->account()->isHttp2Supported() ? 20 : 6;
|
||||
opt._deltaSyncEnabled = false;
|
||||
opt._deltaSyncMinFileSize = false;
|
||||
|
||||
// Previously min/max chunk size values didn't exist, so users might
|
||||
// have setups where the chunk size exceeds the new min/max default
|
||||
// values. To cope with this, adjust min/max to always include the
|
||||
// initial chunk size value.
|
||||
opt._minChunkSize = qMin(opt._minChunkSize, opt._initialChunkSize);
|
||||
opt._maxChunkSize = qMax(opt._maxChunkSize, opt._initialChunkSize);
|
||||
|
||||
QByteArray targetChunkUploadDurationEnv = qgetenv("OWNCLOUD_TARGET_CHUNK_UPLOAD_DURATION");
|
||||
if (!targetChunkUploadDurationEnv.isEmpty()) {
|
||||
opt._targetChunkUploadDuration = std::chrono::milliseconds(targetChunkUploadDurationEnv.toUInt());
|
||||
} else {
|
||||
opt._targetChunkUploadDuration = cfgFile.targetChunkUploadDuration();
|
||||
}
|
||||
opt.fillFromEnvironmentVariables();
|
||||
opt.verifyChunkSizes();
|
||||
|
||||
_engine->setSyncOptions(opt);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ set(libsync_SRCS
|
|||
syncfilestatustracker.cpp
|
||||
localdiscoverytracker.cpp
|
||||
syncresult.cpp
|
||||
syncoptions.cpp
|
||||
theme.cpp
|
||||
clientsideencryption.cpp
|
||||
clientsideencryptionjobs.cpp
|
||||
|
|
|
@ -27,9 +27,8 @@ namespace OCC {
|
|||
*/
|
||||
struct OWNCLOUDSYNC_EXPORT SyncOptions
|
||||
{
|
||||
SyncOptions()
|
||||
: _vfs(new VfsOff)
|
||||
{}
|
||||
SyncOptions();
|
||||
~SyncOptions();
|
||||
|
||||
/** Maximum size (in Bytes) a folder can have without asking for confirmation.
|
||||
* -1 means infinite */
|
||||
|
@ -67,7 +66,28 @@ struct OWNCLOUDSYNC_EXPORT SyncOptions
|
|||
|
||||
/** The maximum number of active jobs in parallel */
|
||||
int _parallelNetworkJobs = 6;
|
||||
|
||||
/** Whether delta-synchronization is enabled */
|
||||
bool _deltaSyncEnabled = false;
|
||||
|
||||
/** What the minimum file size (in Bytes) is for delta-synchronization */
|
||||
qint64 _deltaSyncMinFileSize = 0;
|
||||
|
||||
/** Reads settings from env vars where available.
|
||||
*
|
||||
* Currently reads _initialChunkSize, _minChunkSize, _maxChunkSize,
|
||||
* _targetChunkUploadDuration, _parallelNetworkJobs.
|
||||
*/
|
||||
void fillFromEnvironmentVariables();
|
||||
|
||||
/** Ensure min <= initial <= max
|
||||
*
|
||||
* Previously min/max chunk size values didn't exist, so users might
|
||||
* have setups where the chunk size exceeds the new min/max default
|
||||
* values. To cope with this, adjust min/max to always include the
|
||||
* initial chunk size value.
|
||||
*/
|
||||
void verifyChunkSizes();
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue