mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
This commit adds client-side support for delta-sync, this adds a new 3rdparty submodule `gh:ahmedammar/zsync`. This zsync tree is a modified version of upstream, adding some needed support for the upload path and other requirements. If the server does not announce the required zsync capability then a full upload/download is fallen back to. Delta synchronization can be enabled/disabled using command line, config, or gui options. On both upload and download paths, a check is made for the existance of a zsync metadata file on the server for a given path. This is provided by a dav property called `zsync`, found during discovery phase. If it doesn't exist the code reverts back to a complete upload or download, i.e. previous implementations. In the case of upload, a new zsync metadata file will be uploaded as part of the chunked upload and future synchronizations will be delta-sync capable. Chunked uploads no longer use sequential file names for each chunk id, instead, they are named as the byte offset into the remote file, this is a minimally intrusive modification to allow fo delta-sync and legacy code paths to run seamlessly. A new http header OC-Total-File-Length is sent, which informs the server of the final expected size of the file not just the total transmitted bytes as reported by OC-Total-Length. The seeding and generation of the zsync metadata file is done in a separate thread since this is a cpu intensive task, ensuring main thread is not blocked. This commit closes owncloud/client#179.
106 lines
3.0 KiB
C++
106 lines
3.0 KiB
C++
/*
|
|
* Copyright (C) by Markus Goetz <markus@woboq.com>
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
* for more details.
|
|
*/
|
|
|
|
#ifndef BANDWIDTHMANAGER_H
|
|
#define BANDWIDTHMANAGER_H
|
|
|
|
#include <QObject>
|
|
#include <QLinkedList>
|
|
#include <QTimer>
|
|
#include <QIODevice>
|
|
|
|
namespace OCC {
|
|
|
|
class UploadDevice;
|
|
class GETJob;
|
|
class OwncloudPropagator;
|
|
|
|
/**
|
|
* @brief The BandwidthManager class
|
|
* @ingroup libsync
|
|
*/
|
|
class BandwidthManager : public QObject
|
|
{
|
|
Q_OBJECT
|
|
public:
|
|
BandwidthManager(OwncloudPropagator *p);
|
|
~BandwidthManager();
|
|
|
|
bool usingAbsoluteUploadLimit() { return _currentUploadLimit > 0; }
|
|
bool usingRelativeUploadLimit() { return _currentUploadLimit < 0; }
|
|
bool usingAbsoluteDownloadLimit() { return _currentDownloadLimit > 0; }
|
|
bool usingRelativeDownloadLimit() { return _currentDownloadLimit < 0; }
|
|
|
|
|
|
public slots:
|
|
void registerUploadDevice(UploadDevice *);
|
|
void unregisterUploadDevice(QObject *);
|
|
|
|
void registerDownloadJob(GETJob *);
|
|
void unregisterDownloadJob(QObject *);
|
|
|
|
void absoluteLimitTimerExpired();
|
|
void switchingTimerExpired();
|
|
|
|
void relativeUploadMeasuringTimerExpired();
|
|
void relativeUploadDelayTimerExpired();
|
|
|
|
void relativeDownloadMeasuringTimerExpired();
|
|
void relativeDownloadDelayTimerExpired();
|
|
|
|
private:
|
|
// for switching between absolute and relative bw limiting
|
|
QTimer _switchingTimer;
|
|
|
|
// FIXME this timer and this variable should be replaced
|
|
// by the propagator emitting the changed limit values to us as signal
|
|
OwncloudPropagator *_propagator;
|
|
|
|
// for absolute up/down bw limiting
|
|
QTimer _absoluteLimitTimer;
|
|
|
|
// FIXME merge these two lists
|
|
QLinkedList<UploadDevice *> _absoluteUploadDeviceList;
|
|
QLinkedList<UploadDevice *> _relativeUploadDeviceList;
|
|
|
|
QTimer _relativeUploadMeasuringTimer;
|
|
|
|
// for relative bw limiting, we need to wait this amount before measuring again
|
|
QTimer _relativeUploadDelayTimer;
|
|
|
|
// the device measured
|
|
UploadDevice *_relativeLimitCurrentMeasuredDevice;
|
|
|
|
// for measuring how much progress we made at start
|
|
qint64 _relativeUploadLimitProgressAtMeasuringRestart;
|
|
qint64 _currentUploadLimit;
|
|
|
|
QLinkedList<GETJob *> _downloadJobList;
|
|
QTimer _relativeDownloadMeasuringTimer;
|
|
|
|
// for relative bw limiting, we need to wait this amount before measuring again
|
|
QTimer _relativeDownloadDelayTimer;
|
|
|
|
// the device measured
|
|
GETJob *_relativeLimitCurrentMeasuredJob;
|
|
|
|
// for measuring how much progress we made at start
|
|
qint64 _relativeDownloadLimitProgressAtMeasuringRestart;
|
|
|
|
qint64 _currentDownloadLimit;
|
|
};
|
|
}
|
|
|
|
#endif
|