]> dgit.raspbian.org Git - nextcloud-desktop.git/commitdiff
SocketAPI: Push new status of dirty files regardless when not synced (#4970)
authorJocelyn Turcotte <jturcotte@woboq.com>
Thu, 16 Jun 2016 13:27:10 +0000 (15:27 +0200)
committerGitHub <noreply@github.com>
Thu, 16 Jun 2016 13:27:10 +0000 (15:27 +0200)
The FolderWatcher inserts files to be marked as SYNC and we
currently assume that all file statuses will be updated by the
following sync. It's however possible that the FolderWatcher
notify us of a change that csync won't consider necessary to
propagate, in which case a new status wouldn't be pushed and
the file manager would continue showing this file as syncing.

Re-push the file status when emptying the dirty files list
before propagating to avoid this issue, most likely the OK
status.

src/libsync/syncfilestatustracker.cpp
src/libsync/syncfilestatustracker.h

index d63b79df89c5a391c6f832ee58ac77a338d3f545..19224a38c5bd5b04e4b072e947606627416c07f5 100644 (file)
@@ -76,7 +76,6 @@ SyncFileStatusTracker::SyncFileStatusTracker(SyncEngine *syncEngine)
             SLOT(slotAboutToPropagate(SyncFileItemVector&)));
     connect(syncEngine, SIGNAL(itemCompleted(const SyncFileItem&, const PropagatorJob&)),
             SLOT(slotItemCompleted(const SyncFileItem&)));
-    connect(syncEngine, SIGNAL(started()), SLOT(slotClearDirtyPaths()));
     connect(syncEngine, SIGNAL(started()), SLOT(slotSyncEngineRunningChanged()));
     connect(syncEngine, SIGNAL(finished(bool)), SLOT(slotSyncEngineRunningChanged()));
 }
@@ -156,9 +155,18 @@ void SyncFileStatusTracker::slotAboutToPropagate(SyncFileItemVector& items)
         } else if (showWarningInSocketApi(*item)) {
             _syncProblems[item->_file] = SyncFileStatus::StatusWarning;
         }
+        _dirtyPaths.remove(item->destination());
         emit fileStatusChanged(getSystemDestination(item->destination()), syncFileItemStatus(*item));
     }
 
+    // Some metadata status won't trigger files to be synced, make sure that we
+    // push the OK status for dirty files that don't need to be propagated.
+    // Swap into a copy since fileStatus() reads _dirtyPaths to determine the status
+    QSet<QString> oldDirtyPaths;
+    std::swap(_dirtyPaths, oldDirtyPaths);
+    for (auto it = oldDirtyPaths.cbegin(); it != oldDirtyPaths.cend(); ++it)
+        emit fileStatusChanged(getSystemDestination(*it), fileStatus(*it));
+
     // Make sure to push any status that might have been resolved indirectly since the last sync
     // (like an error file being deleted from disk)
     for (auto it = _syncProblems.begin(); it != _syncProblems.end(); ++it)
@@ -193,13 +201,6 @@ void SyncFileStatusTracker::slotSyncEngineRunningChanged()
     emit fileStatusChanged(_syncEngine->localPath(), syncFileItemStatus(rootSyncFileItem()));
 }
 
-void SyncFileStatusTracker::slotClearDirtyPaths()
-{
-    // We just assume that during a sync all dirty statuses will be resolved
-    // one way or the other.
-    _dirtyPaths.clear();
-}
-
 SyncFileStatus SyncFileStatusTracker::syncFileItemStatus(const SyncFileItem& item)
 {
     // Hack to know if the item was taken from the sync engine (Sync), or from the database (UpToDate)
index d141b4b17883ef78be66872ef59629faadc85b0a..e064f5f9bf16c13e8dd630e4ed88fddcc8f93258 100644 (file)
@@ -47,7 +47,6 @@ private slots:
     void slotAboutToPropagate(SyncFileItemVector& items);
     void slotItemCompleted(const SyncFileItem& item);
     void slotSyncEngineRunningChanged();
-    void slotClearDirtyPaths();
 
 private:
     SyncFileStatus syncFileItemStatus(const SyncFileItem& item);