diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index e86532346..575d72abc 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -606,9 +606,15 @@ bool PropagateDirectory::scheduleNextJob() return false; } + // cache the value of first unfinished subjob bool stopAtDirectory = false; - // FIXME: use the cached value of finished job - for (int i = 0; i < _subJobs.count(); ++i) { + int i = _firstUnfinishedSubJob; + int subJobsCount = _subJobs.count(); + while (i < subJobsCount && _subJobs.at(i)->_state == Finished) { + _firstUnfinishedSubJob = ++i; + } + + for (int i = _firstUnfinishedSubJob; i < subJobsCount; ++i) { if (_subJobs.at(i)->_state == Finished) { continue; } diff --git a/src/libsync/owncloudpropagator.h b/src/libsync/owncloudpropagator.h index b571e64a6..b9862eaaf 100644 --- a/src/libsync/owncloudpropagator.h +++ b/src/libsync/owncloudpropagator.h @@ -195,10 +195,11 @@ public: int _jobsFinished; // number of jobs that have completed int _runningNow; // number of subJobs running right now SyncFileItem::Status _hasError; // NoStatus, or NormalError / SoftError if there was an error + int _firstUnfinishedSubJob; explicit PropagateDirectory(OwncloudPropagator *propagator, const SyncFileItemPtr &item = SyncFileItemPtr(new SyncFileItem)) : PropagatorJob(propagator) - , _firstJob(0), _item(item), _jobsFinished(0), _runningNow(0), _hasError(SyncFileItem::NoStatus) + , _firstJob(0), _item(item), _jobsFinished(0), _runningNow(0), _hasError(SyncFileItem::NoStatus), _firstUnfinishedSubJob(0) { } virtual ~PropagateDirectory() {