Upload: Chunk size can be changed in the config file

Added a new "chunkSize" entry in the General group of the owncloud.cfg
which can be set to the size, in bytes, of the chunks.

This allow user with hude bandwidth to select more optimal chunk size

Issue #4354
This commit is contained in:
Olivier Goffart 2016-01-15 13:16:52 +01:00
parent a41fbc0454
commit d12c0939b9
6 changed files with 29 additions and 11 deletions

View file

@ -49,6 +49,7 @@ static const char skipUpdateCheckC[] = "skipUpdateCheck";
static const char updateCheckIntervalC[] = "updateCheckInterval";
static const char geometryC[] = "geometry";
static const char timeoutC[] = "timeout";
static const char chunkSizeC[] = "chunkSize";
static const char transmissionChecksumC[] = "transmissionChecksum";
static const char proxyHostC[] = "Proxy/host";
@ -120,6 +121,12 @@ int ConfigFile::timeout() const
return settings.value(QLatin1String(timeoutC), 300).toInt(); // default to 5 min
}
quint64 ConfigFile::chunkSize() const
{
QSettings settings(configFile(), QSettings::IniFormat);
return settings.value(QLatin1String(chunkSizeC), 5*1024*1024).toLongLong(); // default to 5 MiB
}
QString ConfigFile::transmissionChecksum() const
{
QSettings settings(configFile(), QSettings::IniFormat);

View file

@ -106,6 +106,7 @@ public:
void setOptionalDesktopNotifications(bool show);
int timeout() const;
quint64 chunkSize() const;
// send a checksum as a header along with the transmission or not.
// possible values:

View file

@ -444,6 +444,20 @@ int OwncloudPropagator::httpTimeout()
return timeout;
}
quint64 OwncloudPropagator::chunkSize()
{
static uint chunkSize;
if (!chunkSize) {
chunkSize = qgetenv("OWNCLOUD_CHUNK_SIZE").toUInt();
if (chunkSize == 0) {
ConfigFile cfg;
chunkSize = cfg.chunkSize();
}
}
return chunkSize;
}
bool OwncloudPropagator::localFileNameClash( const QString& relFile )
{
bool re = false;

View file

@ -317,6 +317,9 @@ public:
// timeout in seconds
static int httpTimeout();
/** returns the size of chunks in bytes */
static quint64 chunkSize();
/** Records that a file was touched by a job.
*
* Thread-safe.
@ -343,6 +346,8 @@ public:
*/
DiskSpaceResult diskSpaceCheck() const;
private slots:
/** Emit the finished signal and make sure it is only emitted once */

View file

@ -60,17 +60,6 @@ static bool fileIsStillChanging(const SyncFileItem & item)
&& msSinceMod > -10000;
}
static qint64 chunkSize() {
static uint chunkSize;
if (!chunkSize) {
chunkSize = qgetenv("OWNCLOUD_CHUNK_SIZE").toUInt();
if (chunkSize == 0) {
chunkSize = 5*1024*1024; // default to 5 MiB
}
}
return chunkSize;
}
PUTFileJob::~PUTFileJob()
{
// Make sure that we destroy the QNetworkReply before our _device of which it keeps an internal pointer.

View file

@ -188,6 +188,8 @@ private:
bool _deleteExisting;
quint64 chunkSize() const { return _propagator->chunkSize(); }
public:
PropagateUploadFileQNAM(OwncloudPropagator* propagator,const SyncFileItemPtr& item)
: PropagateItemJob(propagator, item), _startChunk(0), _currentChunk(0), _chunkCount(0), _transferId(0), _finished(false), _deleteExisting(false) {}