From: Olivier Goffart Date: Mon, 6 Aug 2018 10:53:51 +0000 (+0200) Subject: New discovery algorithm: Call FolderDiscovered X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~21^2~468^2~530 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=9401273daf79d035785ee5ac7e3219f3743af110;p=nextcloud-desktop.git New discovery algorithm: Call FolderDiscovered --- diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index e4cd5b9a5..d765634c6 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -162,30 +162,6 @@ void DiscoveryPhase::startJob(ProcessDirectoryJob *job) job->start(); } -/* FIXME (used to be called every time we were doing a propfind) -void DiscoveryJob::update_job_update_callback(bool local, - const char *dirUrl, - void *userdata) -{ - auto *updateJob = static_cast(userdata); - if (updateJob) { - // Don't wanna overload the UI - if (!updateJob->_lastUpdateProgressCallbackCall.isValid() - || updateJob->_lastUpdateProgressCallbackCall.elapsed() >= 200) { - updateJob->_lastUpdateProgressCallbackCall.start(); - } else { - return; - } - - QByteArray pPath(dirUrl); - int indx = pPath.lastIndexOf('/'); - if (indx > -1) { - const QString path = QUrl::fromPercentEncoding(pPath.mid(indx + 1)); - emit updateJob->folderDiscovered(local, path); - } - } -}*/ - DiscoverySingleDirectoryJob::DiscoverySingleDirectoryJob(const AccountPtr &account, const QString &path, QObject *parent) : QObject(parent) , _subPath(path) diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 2b4a36336..ffbc65350 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -380,6 +380,10 @@ void OCC::SyncEngine::slotItemDiscovered(const OCC::SyncFileItemPtr &item) _needsUpdate = true; _syncItems.append(item); slotNewItem(item); + + if (item->isDirectory()) { + slotFolderDiscovered(item->_etag.isEmpty(), item->_file); + } } void SyncEngine::startSync() @@ -627,9 +631,15 @@ void SyncEngine::slotStartDiscovery() void SyncEngine::slotFolderDiscovered(bool local, const QString &folder) { - // Currently remote and local discovery never run in parallel - // Note: Currently this slot is only called occasionally! See the throttling - // in DiscoveryJob::update_job_update_callback. + // Don't wanna overload the UI + if (!_lastUpdateProgressCallbackCall.isValid()) { + _lastUpdateProgressCallbackCall.start(); // first call + } else if (_lastUpdateProgressCallbackCall.elapsed() < 200) { + return; + } else { + _lastUpdateProgressCallbackCall.start(); + } + if (local) { _progressInfo->_currentDiscoveredLocalFolder = folder; _progressInfo->_currentDiscoveredRemoteFolder.clear(); diff --git a/src/libsync/syncengine.h b/src/libsync/syncengine.h index 90f00a8aa..1343fc493 100644 --- a/src/libsync/syncengine.h +++ b/src/libsync/syncengine.h @@ -289,6 +289,8 @@ private: /** Stores the time since a job touched a file. */ QMultiMap _touchedFiles; + QElapsedTimer _lastUpdateProgressCallbackCall; + /** For clearing the _touchedFiles variable after sync finished */ QTimer _clearTouchedFilesTimer;