_item->_status = status;
- emit itemCompleted(_item);
+ emit propagator()->itemCompleted(_item);
emit finished(status);
}
if( newJob ) {
newJob->setRestoreJobMsg(msg);
_restoreJob.reset(newJob);
- connect(_restoreJob.data(), SIGNAL(itemCompleted(const SyncFileItemPtr &)),
- this, SLOT(slotRestoreJobCompleted(const SyncFileItemPtr &)));
+ connect(_restoreJob.data(), SIGNAL(finished(SyncFileItem::Status)),
+ this, SLOT(slotRestoreJobFinished(SyncFileItem::Status)));
QMetaObject::invokeMethod(newJob, "start");
}
return true;
return false;
}
-void PropagateItemJob::slotRestoreJobCompleted(const SyncFileItem& item )
+void PropagateItemJob::slotRestoreJobFinished(SyncFileItem::Status status)
{
QString msg;
if(_restoreJob) {
_restoreJob->setRestoreJobMsg();
}
- if( item._status == SyncFileItem::Success || item._status == SyncFileItem::Conflict
- || item._status == SyncFileItem::Restoration) {
+ if( status == SyncFileItem::Success || status == SyncFileItem::Conflict
+ || status == SyncFileItem::Restoration) {
done( SyncFileItem::SoftError, msg);
} else {
- done( item._status, tr("A file or folder was removed from a read only share, but restoring failed: %1").arg(item._errorString) );
+ done( status, tr("A file or folder was removed from a read only share, but restoring failed: %1").arg(msg) );
}
}
_rootJob->appendJob(it);
}
- connect(_rootJob.data(), SIGNAL(itemCompleted(const SyncFileItemPtr &)),
- this, SIGNAL(itemCompleted(const SyncFileItemPtr &)));
- connect(_rootJob.data(), SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
connect(_rootJob.data(), SIGNAL(finished(SyncFileItem::Status)), this, SLOT(emitFinished(SyncFileItem::Status)));
- connect(_rootJob.data(), SIGNAL(ready()), this, SLOT(scheduleNextJob()), Qt::QueuedConnection);
qDebug() << "Using QNAM/HTTP parallel code path";
- QTimer::singleShot(0, this, SLOT(scheduleNextJob()));
+ scheduleNextJob();
}
// ownCloud server < 7.0 did not had permissions so we need some other euristics
}
void OwncloudPropagator::scheduleNextJob()
+{
+ QTimer::singleShot(0, this, SLOT(scheduleNextJobImpl()));
+}
+
+void OwncloudPropagator::scheduleNextJobImpl()
{
// TODO: If we see that the automatic up-scaling has a bad impact we
// need to check how to avoid this.
// Making sure we do up/down at same time? https://github.com/owncloud/client/issues/1633
if (_activeJobList.count() < maximumActiveTransferJob()) {
- if (_rootJob->scheduleNextJob()) {
- QTimer::singleShot(0, this, SLOT(scheduleNextJob()));
+ if (_rootJob->scheduleSelfOrChild()) {
+ scheduleNextJob();
}
} else if (_activeJobList.count() < hardMaximumActiveJob()) {
int likelyFinishedQuicklyCount = 0;
}
if (_activeJobList.count() < maximumActiveTransferJob() + likelyFinishedQuicklyCount) {
qDebug() << "Can pump in another request! activeJobs =" << _activeJobList.count();
- if (_rootJob->scheduleNextJob()) {
- QTimer::singleShot(0, this, SLOT(scheduleNextJob()));
+ if (_rootJob->scheduleSelfOrChild()) {
+ scheduleNextJob();
}
}
}
}
+void OwncloudPropagator::reportProgress(const SyncFileItem &item, quint64 bytes)
+{
+ emit progress(item, bytes);
+}
+
AccountPtr OwncloudPropagator::account() const
{
return _account;
}
-bool PropagatorCompositeJob::scheduleNextJob()
+bool PropagatorCompositeJob::scheduleSelfOrChild()
{
if (_state == Finished) {
return false;
}
// If any of the running sub jobs is not parallel, we have to cancel the scheduling
- // of the rest of the list and wait for the blocking job to finish and emit ready().
+ // of the rest of the list and wait for the blocking job to finish and schedule the next one.
auto paral = _runningJobs.at(i)->parallelism();
if (paral == WaitForFinished) {
return false;
if (_jobsToDo.isEmpty() && _tasksToDo.isEmpty() && _runningJobs.isEmpty()) {
finalize();
} else {
- emit ready();
+ propagator()->scheduleNextJob();
}
}
{
if (_firstJob) {
connect(_firstJob.data(), SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotFirstJobFinished(SyncFileItem::Status)));
- connect(_firstJob.data(), SIGNAL(itemCompleted(const SyncFileItemPtr &)), this, SIGNAL(itemCompleted(const SyncFileItemPtr &)));
- connect(_firstJob.data(), SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
- connect(_firstJob.data(), SIGNAL(ready()), this, SIGNAL(ready()));
}
connect(&_subJobs, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobsFinished(SyncFileItem::Status)));
- connect(&_subJobs, SIGNAL(itemCompleted(const SyncFileItemPtr &)), this, SIGNAL(itemCompleted(const SyncFileItemPtr &)));
- connect(&_subJobs, SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
- connect(&_subJobs, SIGNAL(ready()), this, SIGNAL(ready()));
}
PropagatorJob::JobParallelism PropagateDirectory::parallelism()
}
-bool PropagateDirectory::scheduleNextJob()
+bool PropagateDirectory::scheduleSelfOrChild()
{
if (_state == Finished) {
return false;
}
if (_firstJob && _firstJob->_state == NotYetStarted) {
- return _firstJob->scheduleNextJob();
+ return _firstJob->scheduleSelfOrChild();
}
if (_firstJob && _firstJob->_state == Running) {
return false;
}
- return _subJobs.scheduleNextJob();
+ return _subJobs.scheduleSelfOrChild();
}
return;
}
- emit ready();
+ propagator()->scheduleNextJob();
}
void PropagateDirectory::slotSubJobsFinished(SyncFileItem::Status status)
/** Starts this job, or a new subjob
* returns true if a job was started.
*/
- virtual bool scheduleNextJob() = 0;
+ virtual bool scheduleSelfOrChild() = 0;
signals:
/**
* Emitted when the job is fully finished
*/
void finished(SyncFileItem::Status);
- /**
- * Emitted when one item has been completed within a job.
- */
- void itemCompleted(const SyncFileItemPtr &);
-
- /**
- * Emitted when all the sub-jobs have been finished and
- * more jobs might be started (so scheduleNextJob can/must be called again)
- */
- void ready();
-
- void progress(const SyncFileItem& item, quint64 bytes);
-
protected:
OwncloudPropagator *propagator() const;
};
}
protected slots:
- void slotRestoreJobCompleted(const SyncFileItem& );
+ void slotRestoreJobFinished(SyncFileItem::Status status);
private:
QScopedPointer<PropagateItemJob> _restoreJob;
PropagateItemJob(OwncloudPropagator* propagator, const SyncFileItemPtr &item)
: PropagatorJob(propagator), _item(item) {}
- bool scheduleNextJob() Q_DECL_OVERRIDE {
+ bool scheduleSelfOrChild() Q_DECL_OVERRIDE {
if (_state != NotYetStarted) {
return false;
}
_tasksToDo.append(item);
}
- virtual bool scheduleNextJob() Q_DECL_OVERRIDE;
+ virtual bool scheduleSelfOrChild() Q_DECL_OVERRIDE;
virtual JobParallelism parallelism() Q_DECL_OVERRIDE;
virtual void abort() Q_DECL_OVERRIDE {
foreach (PropagatorJob *j, _runningJobs)
bool possiblyRunNextJob(PropagatorJob *next) {
if (next->_state == NotYetStarted) {
connect(next, SIGNAL(finished(SyncFileItem::Status)), this, SLOT(slotSubJobFinished(SyncFileItem::Status)));
- connect(next, SIGNAL(itemCompleted(const SyncFileItemPtr &)), this, SIGNAL(itemCompleted(const SyncFileItemPtr &)));
- connect(next, SIGNAL(progress(const SyncFileItem &,quint64)), this, SIGNAL(progress(const SyncFileItem &,quint64)));
- connect(next, SIGNAL(ready()), this, SIGNAL(ready()));
}
- return next->scheduleNextJob();
+ return next->scheduleSelfOrChild();
}
void slotSubJobFinished(SyncFileItem::Status status);
_subJobs.appendTask(item);
}
- virtual bool scheduleNextJob() Q_DECL_OVERRIDE;
+ virtual bool scheduleSelfOrChild() Q_DECL_OVERRIDE;
virtual JobParallelism parallelism() Q_DECL_OVERRIDE;
virtual void abort() Q_DECL_OVERRIDE {
if (_firstJob)
QString getFilePath(const QString& tmp_file_name) const;
PropagateItemJob *createJob(const SyncFileItemPtr& item);
+ void scheduleNextJob();
+ void reportProgress(const SyncFileItem&, quint64 bytes);
+
void abort() {
_abortRequested.fetchAndStoreOrdered(true);
if (_rootJob) {
_finishedEmited = true;
}
- void scheduleNextJob();
+ void scheduleNextJobImpl();
signals:
void itemCompleted(const SyncFileItemPtr &);
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
// access to signals which are protected in Qt4
friend class PropagateDownloadFile;
+ friend class PropagateItemJob;
friend class PropagateLocalMkdir;
friend class PropagateLocalRename;
friend class PropagateRemoteMove;