File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -98,6 +98,14 @@ class FolderPriorityQueue
9898 return std::make_pair (out.folder , out.priority );
9999 }
100100
101+ Folder *peek () const
102+ {
103+ if (_queue.empty ()) {
104+ return nullptr ;
105+ }
106+ return _queue.top ().folder ;
107+ }
108+
101109private:
102110 // the actual queue
103111 std::priority_queue<Element> _queue;
@@ -176,16 +184,31 @@ void SyncScheduler::startNext()
176184 }
177185
178186 Priority syncPriority = Priority::Low;
187+ QSet<Folder *> seen;
188+ seen.reserve (_queue->size ());
179189 while (!_currentSync) {
180190 if (_queue->empty ()) {
181191 qCInfo (lcSyncScheduler) << u" Queue is empty, no sync to start" ;
182192 return ;
183193 }
194+ if (auto *folder = _queue->peek ()) {
195+ if (seen.contains (folder)) {
196+ // We have seen this folder already, it means all folders in the queue are not syncable
197+ qCInfo (lcSyncScheduler) << u" Skipping sync of" << folder->path () << u" because it was already tried" ;
198+ return ;
199+ }
200+ } else {
201+ std::ignore = _queue->pop ();
202+ continue ;
203+ }
184204 std::tie (_currentSync, syncPriority) = _queue->pop ();
205+ seen.insert (_currentSync);
185206 // If the folder is deleted in the meantime, we skip it
186- if (_currentSync && !_currentSync->isReady ()) {
207+ if (!_currentSync->canSync ()) {
187208 qCInfo (lcSyncScheduler) << u" Skipping sync of" << _currentSync->path () << u" because it is not ready" ;
209+ enqueueFolder (_currentSync, syncPriority);
188210 _currentSync.clear ();
211+ continue ;
189212 }
190213 }
191214
You can’t perform that action at this time.
0 commit comments