Discovery: Add signal for silentlyExcluded files
authorChristian Kamm <mail@ckamm.de>
Tue, 22 Jan 2019 10:29:03 +0000 (11:29 +0100)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:58:37 +0000 (10:58 +0100)
This allows SyncFileStatusTracker to also know about these. After all
its information is used to provide icons for them too.

src/libsync/discovery.cpp
src/libsync/discoveryphase.h
src/libsync/syncengine.cpp
src/libsync/syncfilestatustracker.cpp
src/libsync/syncfilestatustracker.h

index 14d00bc5c45a3cd8e014452926f724b61538e769..d4bf83249b307ba31ec4b79b16b5a1d9bedc8398 100644 (file)
@@ -194,6 +194,7 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const QString &loc
     if (excluded == CSYNC_NOT_EXCLUDED && !isSymlink) {
         return false;
     } else if (excluded == CSYNC_FILE_SILENTLY_EXCLUDED || excluded == CSYNC_FILE_EXCLUDE_AND_REMOVE) {
+        emit _discoveryData->silentlyExcluded(path);
         return true;
     }
 
index 35dedf7cf2796e83a205d61bbe786ff18a4937fe..32c9b1332d1002687d825cd2ef31746968b00d65 100644 (file)
@@ -98,6 +98,7 @@ signals:
     void firstDirectoryPermissions(RemotePermissions);
     void etag(const QString &);
     void finished(const HttpResult<QVector<RemoteInfo>> &result);
+
 private slots:
     void directoryListingIteratedSlot(QString, const QMap<QString, QString> &);
     void lsJobFinishedWithoutErrorSlot();
@@ -194,6 +195,12 @@ signals:
 
     // A new folder was discovered and was not synced because of the confirmation feature
     void newBigFolder(const QString &folder, bool isExternal);
+
+    /** For excluded items that don't show up in itemDiscovered()
+      *
+      * The path is relative to the sync folder, similar to item->_file
+      */
+    void silentlyExcluded(const QString &folderPath);
 };
 
 /// Implementation of DiscoveryPhase::adjustRenamedPath
index fc2c30ce386e1411c537d3b288bd378407db0079..29ddcf6fd945bf20761ec59356570bf1991e5f7a 100644 (file)
@@ -634,6 +634,8 @@ void SyncEngine::slotStartDiscovery()
         finalize(false);
     });
     connect(_discoveryPhase.data(), &DiscoveryPhase::finished, this, &SyncEngine::slotDiscoveryFinished);
+    connect(_discoveryPhase.data(), &DiscoveryPhase::silentlyExcluded,
+        _syncFileStatusTracker.data(), &SyncFileStatusTracker::slotAddSilentlyExcluded);
 
     auto discoveryJob = new ProcessDirectoryJob(SyncFileItemPtr(), ProcessDirectoryJob::NormalQuery, ProcessDirectoryJob::NormalQuery,
         _discoveryPhase.data(), _discoveryPhase.data());
index 78ecba389fd94a9d818b3eae761e2b6374858d53..ed2e92fb080a24946809c8041189741803323903 100644 (file)
@@ -137,6 +137,8 @@ SyncFileStatus SyncFileStatusTracker::fileStatus(const QString &relativePath)
     // update the exclude list at runtime and doing it statically here removes
     // our ability to notify changes through the fileStatusChanged signal,
     // it's an acceptable compromize to treat all exclude types the same.
+    // Update: This extra check shouldn't hurt even though silently excluded files
+    // are now available via slotAddSilentlyExcluded().
     if (_syncEngine->excludedFiles().isExcluded(_syncEngine->localPath() + relativePath,
             _syncEngine->localPath(),
             _syncEngine->ignoreHiddenFiles())) {
@@ -167,6 +169,12 @@ void SyncFileStatusTracker::slotPathTouched(const QString &fileName)
     emit fileStatusChanged(fileName, SyncFileStatus::StatusSync);
 }
 
+void SyncFileStatusTracker::slotAddSilentlyExcluded(const QString &folderPath)
+{
+    _syncProblems[folderPath] = SyncFileStatus::StatusWarning;
+    emit fileStatusChanged(getSystemDestination(folderPath), resolveSyncAndErrorStatus(folderPath, NotShared));
+}
+
 void SyncFileStatusTracker::incSyncCountAndEmitStatusChanged(const QString &relativePath, SharedFlag sharedFlag)
 {
     // Will return 0 (and increase to 1) if the path wasn't in the map yet
index 362c4143c2f38bd82716f8d225d743e5b3d867fc..bd5d73e047187a09f14962da6611227bc91bcfd2 100644 (file)
@@ -40,6 +40,8 @@ public:
 
 public slots:
     void slotPathTouched(const QString &fileName);
+    // path relative to folder
+    void slotAddSilentlyExcluded(const QString &folderPath);
 
 signals:
     void fileStatusChanged(const QString &systemFileName, SyncFileStatus fileStatus);