Ignore upload error items and schedule a new sync in case there are removed items...
authoralex-z <blackslayer4@gmail.com>
Thu, 31 Aug 2023 16:55:56 +0000 (18:55 +0200)
committerbackportbot-nextcloud[bot] <backportbot-nextcloud[bot]@users.noreply.github.com>
Mon, 4 Sep 2023 11:53:25 +0000 (11:53 +0000)
Signed-off-by: alex-z <blackslayer4@gmail.com>
src/libsync/discoveryphase.cpp
src/libsync/discoveryphase.h
src/libsync/owncloudpropagator.cpp
src/libsync/syncengine.cpp

index 27936ad866a26bd7dd5c4dcc7f190bbe21b88494..7783ecee46e6d96bb27eae435a9069e967334951 100644 (file)
@@ -227,6 +227,7 @@ void DiscoveryPhase::enqueueDirectoryToDelete(const QString &path, ProcessDirect
 void DiscoveryPhase::startJob(ProcessDirectoryJob *job)
 {
     ENFORCE(!_currentRootJob);
+    connect(this, &DiscoveryPhase::itemDiscovered, this, &DiscoveryPhase::slotItemDiscovered, Qt::UniqueConnection);
     connect(job, &ProcessDirectoryJob::finished, this, [this, job] {
         ENFORCE(_currentRootJob == sender());
         _currentRootJob = nullptr;
@@ -267,6 +268,16 @@ void DiscoveryPhase::scheduleMoreJobs()
     }
 }
 
+void DiscoveryPhase::slotItemDiscovered(const OCC::SyncFileItemPtr &item)
+{
+    if (item->_instruction == CSYNC_INSTRUCTION_ERROR && item->_direction == SyncFileItem::Up) {
+        _hasUploadErrorItems = true;
+    }
+    if (item->_instruction == CSYNC_INSTRUCTION_REMOVE && item->_direction == SyncFileItem::Down) {
+        _hasDownloadRemovedItems = true;
+    }
+}
+
 DiscoverySingleLocalDirectoryJob::DiscoverySingleLocalDirectoryJob(const AccountPtr &account, const QString &localPath, OCC::Vfs *vfs, QObject *parent)
  : QObject(parent), QRunnable(), _localPath(localPath), _account(account), _vfs(vfs)
 {
index 900584066cd08869234f7aad3964cdabeae75629..6c22db3a58e7d9d9cd69e8289c8df122c518e4a5 100644 (file)
@@ -318,6 +318,9 @@ public:
 
     QStringList _listExclusiveFiles;
 
+    bool _hasUploadErrorItems = false;
+    bool _hasDownloadRemovedItems = false;
+
 signals:
     void fatalError(const QString &errorString, const OCC::ErrorCategory errorCategory);
     void itemDiscovered(const OCC::SyncFileItemPtr &item);
@@ -334,6 +337,9 @@ signals:
     void silentlyExcluded(const QString &folderPath);
 
     void addErrorToGui(const SyncFileItem::Status status, const QString &errorMessage, const QString &subject, const OCC::ErrorCategory category);
+
+private slots:
+    void slotItemDiscovered(const OCC::SyncFileItemPtr &item);
 };
 
 /// Implementation of DiscoveryPhase::adjustRenamedPath
index 8b340562fa48494694550800874be3d02e37a541..488a83a3f0ff5a54c64019cd7d0628e49d28da54 100644 (file)
@@ -510,10 +510,12 @@ void OwncloudPropagator::start(SyncFileItemVector &&items)
                 } while (index > 0);
             }
         }
-        items.erase(std::remove_if(items.begin(), items.end(), [&names](auto i) {
-            return !names.contains(QStringRef { &i->_file });
-        }),
-            items.end());
+        items.erase(std::remove_if(items.begin(),
+                                   items.end(),
+                                   [&names](auto i) {
+                                       return !names.contains(QStringRef{&i->_file});
+                                   }),
+                    items.end());
     }
 
     QStringList files;
index 47d88fa689df38109539ee1a187864fc91fe321f..35f6d59139bdaac8ad7bc3703d71fe8b1e921610 100644 (file)
@@ -810,6 +810,15 @@ void SyncEngine::slotDiscoveryFinished()
             slotUnscheduleFilesDelayedSync();
         }
 
+        if (_discoveryPhase->_hasDownloadRemovedItems && _discoveryPhase->_hasUploadErrorItems) {
+            for (const auto &item : _syncItems) {
+                if (item->_instruction == CSYNC_INSTRUCTION_ERROR && item->_direction == SyncFileItem::Up) {
+                    item->_instruction = CSYNC_INSTRUCTION_IGNORE;
+                }
+            }
+            _anotherSyncNeeded = ImmediateFollowUp;
+        }
+
         Q_ASSERT(std::is_sorted(_syncItems.begin(), _syncItems.end()));
 
         qCInfo(lcEngine) << "#### Reconcile (aboutToPropagate) #################################################### " << _stopWatch.addLapTime(QStringLiteral("Reconcile (aboutToPropagate)")) << "ms";