diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index 27936ad866a26..7783ecee46e6d 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -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) { diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index 900584066cd08..6c22db3a58e7d 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -318,6 +318,9 @@ class DiscoveryPhase : public QObject 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 @@ class DiscoveryPhase : public QObject 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 diff --git a/src/libsync/owncloudpropagator.cpp b/src/libsync/owncloudpropagator.cpp index 8b340562fa484..488a83a3f0ff5 100644 --- a/src/libsync/owncloudpropagator.cpp +++ b/src/libsync/owncloudpropagator.cpp @@ -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; diff --git a/src/libsync/syncengine.cpp b/src/libsync/syncengine.cpp index 47d88fa689df3..35f6d59139bda 100644 --- a/src/libsync/syncengine.cpp +++ b/src/libsync/syncengine.cpp @@ -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";