diff --git a/src/cmd/cmd.cpp b/src/cmd/cmd.cpp index 5b1de5e64..ac0a7051e 100644 --- a/src/cmd/cmd.cpp +++ b/src/cmd/cmd.cpp @@ -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); diff --git a/src/gui/folder.cpp b/src/gui/folder.cpp index 4fb5a259e..814f83f82 100644 --- a/src/gui/folder.cpp +++ b/src/gui/folder.cpp @@ -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); } diff --git a/src/libsync/CMakeLists.txt b/src/libsync/CMakeLists.txt index 7e6bee31f..3c38c6374 100644 --- a/src/libsync/CMakeLists.txt +++ b/src/libsync/CMakeLists.txt @@ -51,6 +51,7 @@ set(libsync_SRCS syncfilestatustracker.cpp localdiscoverytracker.cpp syncresult.cpp + syncoptions.cpp theme.cpp clientsideencryption.cpp clientsideencryptionjobs.cpp diff --git a/src/libsync/syncoptions.h b/src/libsync/syncoptions.h index cc792aa9b..57d1969ba 100644 --- a/src/libsync/syncoptions.h +++ b/src/libsync/syncoptions.h @@ -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(); }; - }