2014-02-06 10:50:16 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Olivier Goffart <ogoffart@owncloud.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.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
2014-02-18 10:52:38 +00:00
|
|
|
#include "owncloudpropagator.h"
|
2014-02-06 10:50:16 +00:00
|
|
|
#include "networkjobs.h"
|
|
|
|
|
2014-02-18 10:52:38 +00:00
|
|
|
#include <QBuffer>
|
|
|
|
#include <QFile>
|
2017-03-24 14:01:50 +00:00
|
|
|
#include <QElapsedTimer>
|
2014-02-06 10:50:16 +00:00
|
|
|
|
|
|
|
|
2014-11-09 21:34:07 +00:00
|
|
|
namespace OCC {
|
2017-05-09 12:24:11 +00:00
|
|
|
|
2017-03-30 11:46:20 +00:00
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lcPutJob)
|
2017-05-09 12:24:11 +00:00
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lcPropagateUpload)
|
2020-05-13 15:34:41 +00:00
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lcPropagateUploadV1)
|
|
|
|
Q_DECLARE_LOGGING_CATEGORY(lcPropagateUploadNG)
|
2017-05-09 12:24:11 +00:00
|
|
|
|
2014-11-14 15:40:13 +00:00
|
|
|
class BandwidthManager;
|
2014-02-06 10:50:16 +00:00
|
|
|
|
2015-06-29 16:56:09 +00:00
|
|
|
/**
|
|
|
|
* @brief The UploadDevice class
|
|
|
|
* @ingroup libsync
|
2015-06-26 15:07:47 +00:00
|
|
|
*/
|
2014-11-14 15:40:13 +00:00
|
|
|
class UploadDevice : public QIODevice
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2014-02-10 12:00:22 +00:00
|
|
|
public:
|
2019-06-06 10:22:02 +00:00
|
|
|
UploadDevice(const QString &fileName, qint64 start, qint64 size, BandwidthManager *bwm);
|
2021-08-17 10:39:31 +00:00
|
|
|
~UploadDevice() override;
|
2015-01-14 14:14:17 +00:00
|
|
|
|
2019-06-06 10:22:02 +00:00
|
|
|
bool open(QIODevice::OpenMode mode) override;
|
|
|
|
void close() override;
|
2015-01-14 14:14:17 +00:00
|
|
|
|
2018-11-12 17:39:50 +00:00
|
|
|
qint64 writeData(const char *, qint64) override;
|
|
|
|
qint64 readData(char *data, qint64 maxlen) override;
|
2022-09-30 17:12:08 +00:00
|
|
|
[[nodiscard]] bool atEnd() const override;
|
|
|
|
[[nodiscard]] qint64 size() const override;
|
|
|
|
[[nodiscard]] qint64 bytesAvailable() const override;
|
|
|
|
[[nodiscard]] bool isSequential() const override;
|
2018-11-12 17:39:50 +00:00
|
|
|
bool seek(qint64 pos) override;
|
2014-02-10 12:00:22 +00:00
|
|
|
|
2014-11-14 15:40:13 +00:00
|
|
|
void setBandwidthLimited(bool);
|
|
|
|
bool isBandwidthLimited() { return _bandwidthLimited; }
|
|
|
|
void setChoked(bool);
|
|
|
|
bool isChoked() { return _choked; }
|
|
|
|
void giveBandwidthQuota(qint64 bwq);
|
2015-04-27 13:04:44 +00:00
|
|
|
|
|
|
|
signals:
|
|
|
|
|
2014-11-14 15:40:13 +00:00
|
|
|
private:
|
2019-06-06 10:22:02 +00:00
|
|
|
/// The local file to read data from
|
|
|
|
QFile _file;
|
|
|
|
|
|
|
|
/// Start of the file data to use
|
|
|
|
qint64 _start = 0;
|
|
|
|
/// Amount of file data after _start to use
|
|
|
|
qint64 _size = 0;
|
|
|
|
/// Position between _start and _start+_size
|
|
|
|
qint64 _read = 0;
|
2015-01-14 11:48:38 +00:00
|
|
|
|
2015-01-14 13:27:24 +00:00
|
|
|
// Bandwidth manager related
|
|
|
|
QPointer<BandwidthManager> _bandwidthManager;
|
2020-12-10 18:52:58 +00:00
|
|
|
qint64 _bandwidthQuota = 0;
|
|
|
|
qint64 _readWithProgress = 0;
|
|
|
|
bool _bandwidthLimited = false; // if _bandwidthQuota will be used
|
|
|
|
bool _choked = false; // if upload is paused (readData() will return 0)
|
2015-01-14 11:48:38 +00:00
|
|
|
friend class BandwidthManager;
|
2017-09-25 09:58:30 +00:00
|
|
|
public slots:
|
2014-11-14 15:40:13 +00:00
|
|
|
void slotJobUploadProgress(qint64 sent, qint64 t);
|
2014-02-10 12:00:22 +00:00
|
|
|
};
|
|
|
|
|
2015-06-29 16:56:09 +00:00
|
|
|
/**
|
|
|
|
* @brief The PUTFileJob class
|
|
|
|
* @ingroup libsync
|
2015-06-26 15:07:47 +00:00
|
|
|
*/
|
2014-02-06 10:50:16 +00:00
|
|
|
class PUTFileJob : public AbstractNetworkJob
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2015-05-12 14:36:40 +00:00
|
|
|
|
|
|
|
private:
|
2017-03-03 10:20:53 +00:00
|
|
|
QIODevice *_device;
|
2014-02-06 10:50:16 +00:00
|
|
|
QMap<QByteArray, QByteArray> _headers;
|
2014-04-30 15:54:14 +00:00
|
|
|
QString _errorString;
|
2016-08-02 11:48:56 +00:00
|
|
|
QUrl _url;
|
2017-03-24 14:01:50 +00:00
|
|
|
QElapsedTimer _requestTimer;
|
2014-02-06 10:50:16 +00:00
|
|
|
|
|
|
|
public:
|
2014-02-17 12:48:56 +00:00
|
|
|
// Takes ownership of the device
|
2019-05-08 17:41:48 +00:00
|
|
|
explicit PUTFileJob(AccountPtr account, const QString &path, std::unique_ptr<QIODevice> device,
|
2018-11-12 17:46:39 +00:00
|
|
|
const QMap<QByteArray, QByteArray> &headers, int chunk, QObject *parent = nullptr)
|
2017-03-03 10:20:53 +00:00
|
|
|
: AbstractNetworkJob(account, path, parent)
|
2019-05-08 17:41:48 +00:00
|
|
|
, _device(device.release())
|
2017-03-03 10:20:53 +00:00
|
|
|
, _headers(headers)
|
|
|
|
, _chunk(chunk)
|
|
|
|
{
|
|
|
|
_device->setParent(this);
|
|
|
|
}
|
2019-05-08 17:41:48 +00:00
|
|
|
explicit PUTFileJob(AccountPtr account, const QUrl &url, std::unique_ptr<QIODevice> device,
|
2018-11-12 17:46:39 +00:00
|
|
|
const QMap<QByteArray, QByteArray> &headers, int chunk, QObject *parent = nullptr)
|
2016-08-02 11:48:56 +00:00
|
|
|
: AbstractNetworkJob(account, QString(), parent)
|
2019-05-08 17:41:48 +00:00
|
|
|
, _device(device.release())
|
2016-08-02 11:48:56 +00:00
|
|
|
, _headers(headers)
|
2017-03-03 10:20:53 +00:00
|
|
|
, _url(url)
|
|
|
|
, _chunk(chunk)
|
|
|
|
{
|
|
|
|
_device->setParent(this);
|
|
|
|
}
|
2021-08-17 10:39:31 +00:00
|
|
|
~PUTFileJob() override;
|
2014-09-15 15:55:55 +00:00
|
|
|
|
|
|
|
int _chunk;
|
2014-02-06 10:50:16 +00:00
|
|
|
|
2018-11-12 17:43:58 +00:00
|
|
|
void start() override;
|
2014-02-06 10:50:16 +00:00
|
|
|
|
2019-06-21 09:34:59 +00:00
|
|
|
bool finished() override;
|
2014-02-06 10:50:16 +00:00
|
|
|
|
2017-08-10 22:03:03 +00:00
|
|
|
QIODevice *device()
|
|
|
|
{
|
|
|
|
return _device;
|
|
|
|
}
|
|
|
|
|
2022-09-30 17:12:08 +00:00
|
|
|
[[nodiscard]] QString errorString() const override
|
2014-04-30 15:54:14 +00:00
|
|
|
{
|
2017-03-23 14:53:22 +00:00
|
|
|
return _errorString.isEmpty() ? AbstractNetworkJob::errorString() : _errorString;
|
2015-01-30 08:16:14 +00:00
|
|
|
}
|
2014-04-30 15:54:14 +00:00
|
|
|
|
2022-09-30 17:12:08 +00:00
|
|
|
[[nodiscard]] std::chrono::milliseconds msSinceStart() const
|
2017-03-24 14:01:50 +00:00
|
|
|
{
|
2018-01-23 21:51:25 +00:00
|
|
|
return std::chrono::milliseconds(_requestTimer.elapsed());
|
2017-03-24 14:01:50 +00:00
|
|
|
}
|
|
|
|
|
2014-02-06 10:50:16 +00:00
|
|
|
signals:
|
|
|
|
void finishedSignal();
|
2014-03-14 12:03:16 +00:00
|
|
|
void uploadProgress(qint64, qint64);
|
2015-04-27 13:04:44 +00:00
|
|
|
|
2014-02-06 10:50:16 +00:00
|
|
|
};
|
|
|
|
|
2015-06-29 16:56:09 +00:00
|
|
|
/**
|
2015-10-05 03:20:09 +00:00
|
|
|
* @brief This job implements the asynchronous PUT
|
2015-06-26 15:07:47 +00:00
|
|
|
*
|
2018-06-25 15:47:52 +00:00
|
|
|
* If the server replies to a PUT with a OC-JobStatus-Location path, we will query this url until the server
|
|
|
|
* replies with an etag.
|
2015-06-29 16:56:09 +00:00
|
|
|
* @ingroup libsync
|
2015-03-04 07:42:24 +00:00
|
|
|
*/
|
2014-07-25 11:30:48 +00:00
|
|
|
class PollJob : public AbstractNetworkJob
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2014-07-28 10:12:52 +00:00
|
|
|
SyncJournalDb *_journal;
|
|
|
|
QString _localPath;
|
2017-05-17 08:55:42 +00:00
|
|
|
|
2014-07-25 11:30:48 +00:00
|
|
|
public:
|
2015-04-15 13:19:11 +00:00
|
|
|
SyncFileItemPtr _item;
|
2014-07-25 11:30:48 +00:00
|
|
|
// Takes ownership of the device
|
2015-04-15 13:19:11 +00:00
|
|
|
explicit PollJob(AccountPtr account, const QString &path, const SyncFileItemPtr &item,
|
2014-07-28 10:12:52 +00:00
|
|
|
SyncJournalDb *journal, const QString &localPath, QObject *parent)
|
|
|
|
: AbstractNetworkJob(account, path, parent)
|
|
|
|
, _journal(journal)
|
|
|
|
, _localPath(localPath)
|
|
|
|
, _item(item)
|
|
|
|
{
|
|
|
|
}
|
2014-07-25 11:30:48 +00:00
|
|
|
|
2018-11-12 17:39:50 +00:00
|
|
|
void start() override;
|
|
|
|
bool finished() override;
|
2014-07-25 11:30:48 +00:00
|
|
|
|
|
|
|
signals:
|
2014-07-28 10:12:52 +00:00
|
|
|
void finishedSignal();
|
2014-07-25 11:30:48 +00:00
|
|
|
};
|
|
|
|
|
2017-12-20 23:35:23 +00:00
|
|
|
class PropagateUploadEncrypted;
|
|
|
|
|
2015-06-29 16:56:09 +00:00
|
|
|
/**
|
2016-05-20 08:26:02 +00:00
|
|
|
* @brief The PropagateUploadFileCommon class is the code common between all chunking algorithms
|
2015-06-29 16:56:09 +00:00
|
|
|
* @ingroup libsync
|
2016-05-20 08:26:02 +00:00
|
|
|
*
|
|
|
|
* State Machine:
|
|
|
|
*
|
|
|
|
* +---> start() --> (delete job) -------+
|
|
|
|
* | |
|
|
|
|
* +--> slotComputeContentChecksum() <---+
|
|
|
|
* |
|
|
|
|
* v
|
|
|
|
* slotComputeTransmissionChecksum()
|
|
|
|
* |
|
|
|
|
* v
|
|
|
|
* slotStartUpload() -> doStartUpload()
|
|
|
|
* .
|
|
|
|
* .
|
|
|
|
* v
|
|
|
|
* finalize() or abortWithError() or startPollJob()
|
2015-06-26 15:07:47 +00:00
|
|
|
*/
|
2016-05-20 08:26:02 +00:00
|
|
|
class PropagateUploadFileCommon : public PropagateItemJob
|
|
|
|
{
|
2014-02-06 10:50:16 +00:00
|
|
|
Q_OBJECT
|
2015-03-04 07:42:24 +00:00
|
|
|
|
2021-01-21 15:07:30 +00:00
|
|
|
struct UploadStatus {
|
|
|
|
SyncFileItem::Status status = SyncFileItem::NoStatus;
|
|
|
|
QString message;
|
|
|
|
};
|
|
|
|
|
2016-05-20 08:26:02 +00:00
|
|
|
protected:
|
2016-01-06 09:01:22 +00:00
|
|
|
QVector<AbstractNetworkJob *> _jobs; /// network jobs that are currently in transit
|
2017-01-26 12:41:04 +00:00
|
|
|
bool _finished BITFIELD(1); /// Tells that all the jobs have been finished
|
|
|
|
bool _deleteExisting BITFIELD(1);
|
2015-05-12 14:36:40 +00:00
|
|
|
|
2018-10-08 10:04:54 +00:00
|
|
|
/** Whether an abort is currently ongoing.
|
|
|
|
*
|
|
|
|
* Important to avoid duplicate aborts since each finishing PUTFileJob might
|
|
|
|
* trigger an abort on error.
|
|
|
|
*/
|
|
|
|
bool _aborting BITFIELD(1);
|
|
|
|
|
2017-11-28 20:28:06 +00:00
|
|
|
/* This is a minified version of the SyncFileItem,
|
|
|
|
* that holds only the specifics about the file that's
|
|
|
|
* being uploaded.
|
|
|
|
*
|
|
|
|
* This is needed if we wanna apply changes on the file
|
|
|
|
* that's being uploaded while keeping the original on disk.
|
|
|
|
*/
|
|
|
|
struct UploadFileInfo {
|
|
|
|
QString _file; /// I'm still unsure if I should use a SyncFilePtr here.
|
2017-11-28 21:17:29 +00:00
|
|
|
QString _path; /// the full path on disk.
|
2023-02-06 08:14:48 +00:00
|
|
|
qint64 _size = 0LL;
|
2017-11-28 20:28:06 +00:00
|
|
|
};
|
|
|
|
UploadFileInfo _fileToUpload;
|
2017-06-14 10:14:46 +00:00
|
|
|
QByteArray _transmissionChecksumHeader;
|
2015-11-23 10:53:06 +00:00
|
|
|
|
2014-02-06 10:50:16 +00:00
|
|
|
public:
|
2020-07-01 11:19:08 +00:00
|
|
|
PropagateUploadFileCommon(OwncloudPropagator *propagator, const SyncFileItemPtr &item);
|
2016-01-06 09:01:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether an existing entity with the same name may be deleted before
|
|
|
|
* the upload.
|
|
|
|
*
|
|
|
|
* Default: false.
|
|
|
|
*/
|
|
|
|
void setDeleteExisting(bool enabled);
|
|
|
|
|
2017-12-04 20:33:43 +00:00
|
|
|
/* start should setup the file, path and size that will be send to the server */
|
2018-11-12 17:39:50 +00:00
|
|
|
void start() override;
|
2017-12-20 22:36:49 +00:00
|
|
|
void setupEncryptedFile(const QString& path, const QString& filename, quint64 size);
|
2017-12-17 21:38:43 +00:00
|
|
|
void setupUnencryptedFile();
|
2017-12-04 21:27:13 +00:00
|
|
|
void startUploadFile();
|
2017-12-24 15:30:39 +00:00
|
|
|
void callUnlockFolder();
|
2018-11-12 17:39:50 +00:00
|
|
|
bool isLikelyFinishedQuickly() override { return _item->_size < propagator()->smallFileSize(); }
|
2016-10-20 07:15:34 +00:00
|
|
|
|
2014-02-06 10:50:16 +00:00
|
|
|
private slots:
|
2016-01-06 09:01:22 +00:00
|
|
|
void slotComputeContentChecksum();
|
2016-05-20 08:26:02 +00:00
|
|
|
// Content checksum computed, compute the transmission checksum
|
|
|
|
void slotComputeTransmissionChecksum(const QByteArray &contentChecksumType, const QByteArray &contentChecksum);
|
|
|
|
// transmission checksum computed, prepare the upload
|
|
|
|
void slotStartUpload(const QByteArray &transmissionChecksumType, const QByteArray &transmissionChecksum);
|
2021-01-21 11:19:41 +00:00
|
|
|
// invoked when encrypted folder lock has been released
|
|
|
|
void slotFolderUnlocked(const QByteArray &folderId, int httpReturnCode);
|
2023-06-02 11:55:08 +00:00
|
|
|
// invoked on internal error to unlock a folder and failed
|
2021-01-21 11:19:41 +00:00
|
|
|
void slotOnErrorStartFolderUnlock(SyncFileItem::Status status, const QString &errorString);
|
2017-05-17 08:55:42 +00:00
|
|
|
|
2016-05-20 08:26:02 +00:00
|
|
|
public:
|
|
|
|
virtual void doStartUpload() = 0;
|
2015-05-15 13:39:26 +00:00
|
|
|
|
2014-07-25 11:30:48 +00:00
|
|
|
void startPollJob(const QString &path);
|
2016-05-20 08:26:02 +00:00
|
|
|
void finalize();
|
2015-01-14 11:48:38 +00:00
|
|
|
void abortWithError(SyncFileItem::Status status, const QString &error);
|
2016-05-20 08:26:02 +00:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void slotJobDestroyed(QObject *job);
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void slotPollFinished();
|
|
|
|
|
|
|
|
protected:
|
2022-10-11 14:10:53 +00:00
|
|
|
void done(SyncFileItem::Status status, const QString &errorString = QString(), const ErrorCategory category = ErrorCategory::NoError) override;
|
2018-03-27 08:39:58 +00:00
|
|
|
|
2017-08-10 22:03:03 +00:00
|
|
|
/**
|
2018-05-14 11:07:39 +00:00
|
|
|
* Aborts all running network jobs, except for the ones that mayAbortJob
|
|
|
|
* returns false on and, for async aborts, emits abortFinished when done.
|
2017-08-10 22:03:03 +00:00
|
|
|
*/
|
2018-05-14 11:07:39 +00:00
|
|
|
void abortNetworkJobs(
|
|
|
|
AbortType abortType,
|
|
|
|
const std::function<bool(AbstractNetworkJob *job)> &mayAbortJob);
|
2017-08-10 22:03:03 +00:00
|
|
|
|
2017-01-13 13:44:45 +00:00
|
|
|
/**
|
|
|
|
* Checks whether the current error is one that should reset the whole
|
|
|
|
* transfer if it happens too often. If so: Bump UploadInfo::errorCount
|
|
|
|
* and maybe perform the reset.
|
|
|
|
*/
|
|
|
|
void checkResettingErrors();
|
|
|
|
|
2017-07-07 12:12:10 +00:00
|
|
|
/**
|
|
|
|
* Error handling functionality that is shared between jobs.
|
|
|
|
*/
|
|
|
|
void commonErrorHandling(AbstractNetworkJob *job);
|
|
|
|
|
2018-05-16 13:08:33 +00:00
|
|
|
/**
|
|
|
|
* Increases the timeout for the final MOVE/PUT for large files.
|
|
|
|
*
|
|
|
|
* This is an unfortunate workaround since the drawback is not being able to
|
|
|
|
* detect real disconnects in a timely manner. Shall go away when the server
|
|
|
|
* response starts coming quicker, or there is some sort of async api.
|
|
|
|
*
|
|
|
|
* See #6527, enterprise#2480
|
|
|
|
*/
|
2019-02-13 09:15:33 +00:00
|
|
|
static void adjustLastJobTimeout(AbstractNetworkJob *job, qint64 fileSize);
|
2018-05-16 13:08:33 +00:00
|
|
|
|
2018-06-25 15:47:52 +00:00
|
|
|
/** Bases headers that need to be sent on the PUT, or in the MOVE for chunking-ng */
|
2016-05-20 08:26:02 +00:00
|
|
|
QMap<QByteArray, QByteArray> headers();
|
2017-12-20 23:35:23 +00:00
|
|
|
private:
|
2023-02-06 09:38:59 +00:00
|
|
|
PropagateUploadEncrypted *_uploadEncryptedHelper = nullptr;
|
|
|
|
bool _uploadingEncrypted = false;
|
2021-01-21 15:07:30 +00:00
|
|
|
UploadStatus _uploadStatus;
|
2016-05-20 08:26:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup libsync
|
|
|
|
*
|
2023-06-02 11:55:08 +00:00
|
|
|
* Propagation job, implementing the old chunking algorithm
|
2016-05-20 08:26:02 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
class PropagateUploadFileV1 : public PropagateUploadFileCommon
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* That's the start chunk that was stored in the database for resuming.
|
|
|
|
* In the non-resuming case it is 0.
|
|
|
|
* If we are resuming, this is the first chunk we need to send
|
|
|
|
*/
|
2017-09-28 08:03:04 +00:00
|
|
|
int _startChunk = 0;
|
2016-05-20 08:26:02 +00:00
|
|
|
/**
|
|
|
|
* This is the next chunk that we need to send. Starting from 0 even if _startChunk != 0
|
|
|
|
* (In other words, _startChunk + _currentChunk is really the number of the chunk we need to send next)
|
|
|
|
* (In other words, _currentChunk is the number of the chunk that we already sent or started sending)
|
|
|
|
*/
|
2017-09-28 08:03:04 +00:00
|
|
|
int _currentChunk = 0;
|
|
|
|
int _chunkCount = 0; /// Total number of chunks for this file
|
2019-02-13 09:15:33 +00:00
|
|
|
uint _transferId = 0; /// transfer id (part of the url)
|
2016-05-20 08:26:02 +00:00
|
|
|
|
2022-09-30 17:12:08 +00:00
|
|
|
[[nodiscard]] qint64 chunkSize() const {
|
2017-06-20 18:27:26 +00:00
|
|
|
// Old chunking does not use dynamic chunking algorithm, and does not adjusts the chunk size respectively,
|
|
|
|
// thus this value should be used as the one classifing item to be chunked
|
|
|
|
return propagator()->syncOptions()._initialChunkSize;
|
|
|
|
}
|
2016-05-20 08:26:02 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
PropagateUploadFileV1(OwncloudPropagator *propagator, const SyncFileItemPtr &item)
|
|
|
|
: PropagateUploadFileCommon(propagator, item)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-11-12 17:39:50 +00:00
|
|
|
void doStartUpload() override;
|
2017-08-10 22:03:03 +00:00
|
|
|
public slots:
|
2022-10-24 14:00:50 +00:00
|
|
|
void abort(OCC::PropagatorJob::AbortType abortType) override;
|
2016-05-20 08:26:02 +00:00
|
|
|
private slots:
|
|
|
|
void startNextChunk();
|
|
|
|
void slotPutFinished();
|
|
|
|
void slotUploadProgress(qint64, qint64);
|
2014-02-10 12:00:22 +00:00
|
|
|
};
|
|
|
|
|
2016-08-02 11:48:56 +00:00
|
|
|
/**
|
|
|
|
* @ingroup libsync
|
|
|
|
*
|
2023-06-02 11:55:08 +00:00
|
|
|
* Propagation job, implementing the new chunking algorithm
|
2016-08-02 11:48:56 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
class PropagateUploadFileNG : public PropagateUploadFileCommon
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
2019-02-13 09:15:33 +00:00
|
|
|
qint64 _sent = 0; /// amount of data (bytes) that was already sent
|
2017-09-28 08:03:04 +00:00
|
|
|
uint _transferId = 0; /// transfer id (part of the url)
|
|
|
|
int _currentChunk = 0; /// Id of the next chunk that will be sent
|
2019-02-13 09:15:33 +00:00
|
|
|
qint64 _currentChunkSize = 0; /// current chunk size
|
2017-09-28 08:03:04 +00:00
|
|
|
bool _removeJobError = false; /// If not null, there was an error removing the job
|
2016-09-10 10:30:14 +00:00
|
|
|
|
|
|
|
// Map chunk number with its size from the PROPFIND on resume.
|
|
|
|
// (Only used from slotPropfindIterate/slotPropfindFinished because the LsColJob use signals to report data.)
|
2017-01-20 15:03:50 +00:00
|
|
|
struct ServerChunkInfo
|
|
|
|
{
|
2023-02-06 08:14:48 +00:00
|
|
|
qint64 size = 0LL;
|
2017-01-20 15:03:50 +00:00
|
|
|
QString originalName;
|
|
|
|
};
|
2019-02-13 09:15:33 +00:00
|
|
|
QMap<qint64, ServerChunkInfo> _serverChunks;
|
2016-08-02 11:48:56 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the URL of a chunk.
|
|
|
|
* If chunk == -1, returns the URL of the parent folder containing the chunks
|
|
|
|
*/
|
|
|
|
QUrl chunkUrl(int chunk = -1);
|
|
|
|
|
|
|
|
public:
|
2017-03-24 14:01:50 +00:00
|
|
|
PropagateUploadFileNG(OwncloudPropagator *propagator, const SyncFileItemPtr &item)
|
|
|
|
: PropagateUploadFileCommon(propagator, item)
|
|
|
|
{
|
|
|
|
}
|
2016-08-02 11:48:56 +00:00
|
|
|
|
2018-11-12 17:39:50 +00:00
|
|
|
void doStartUpload() override;
|
2016-12-07 21:35:50 +00:00
|
|
|
|
2016-08-02 15:14:44 +00:00
|
|
|
private:
|
|
|
|
void startNewUpload();
|
|
|
|
void startNextChunk();
|
2017-08-10 22:03:03 +00:00
|
|
|
public slots:
|
2022-10-24 14:00:50 +00:00
|
|
|
void abort(OCC::PropagateUploadFileNG::AbortType abortType) override;
|
2016-08-02 11:48:56 +00:00
|
|
|
private slots:
|
2016-08-02 15:14:44 +00:00
|
|
|
void slotPropfindFinished();
|
|
|
|
void slotPropfindFinishedWithError();
|
2016-08-03 15:43:03 +00:00
|
|
|
void slotPropfindIterate(const QString &name, const QMap<QString, QString> &properties);
|
2016-10-31 16:44:00 +00:00
|
|
|
void slotDeleteJobFinished();
|
2021-02-17 13:30:26 +00:00
|
|
|
void slotMkColFinished();
|
2016-08-02 11:48:56 +00:00
|
|
|
void slotPutFinished();
|
|
|
|
void slotMoveJobFinished();
|
|
|
|
void slotUploadProgress(qint64, qint64);
|
|
|
|
};
|
2014-02-06 10:50:16 +00:00
|
|
|
}
|