From: Markus Goetz Date: Fri, 6 Sep 2019 10:58:56 +0000 (+0200) Subject: Reconcile: Sort already during discovery #7445 X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~184 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=09a0dbbf82a1c02dc6eec30faa1cdb6d47cb6553;p=nextcloud-desktop.git Reconcile: Sort already during discovery #7445 --- diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 33ad10c03..806e92c23 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -402,7 +402,11 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item) // if the item is on blacklist, the instruction was set to ERROR checkErrorBlacklisting(*item); _needsUpdate = true; - _syncItems.append(item); + + // Insert sorted + auto it = std::lower_bound( _syncItems.begin(), _syncItems.end(), item ); // the _syncItems is sorted + _syncItems.insert( it, item ); + slotNewItem(item); if (item->isDirectory()) { @@ -742,14 +746,17 @@ void SyncEngine::slotDiscoveryFinished() _anotherSyncNeeded = ImmediateFollowUp; } - // Sort items per destination - std::sort(_syncItems.begin(), _syncItems.end()); + Q_ASSERT(std::is_sorted(_syncItems.begin(), _syncItems.end())); + + qCInfo(lcEngine) << "#### Reconcile (aboutToPropagate) #################################################### " << _stopWatch.addLapTime(QLatin1String("Reconcile (aboutToPropagate)")) << "ms"; _localDiscoveryPaths.clear(); // To announce the beginning of the sync emit aboutToPropagate(_syncItems); + qCInfo(lcEngine) << "#### Reconcile (aboutToPropagate OK) #################################################### "<< _stopWatch.addLapTime(QLatin1String("Reconcile (aboutToPropagate OK)")) << "ms"; + // it's important to do this before ProgressInfo::start(), to announce start of new sync _progressInfo->_status = ProgressInfo::Propagation; emit transmissionProgress(*_progressInfo);