From 7a7926e8f8ffbea5e11846c9e6b39c283de3cb56 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Tue, 5 Mar 2024 12:09:45 +0100 Subject: [PATCH] fix missing tracking for some item rename operations will fix mishandling of rename of a single file to multiple places during discovery Signed-off-by: Matthieu Gallien --- src/libsync/discovery.cpp | 3 +++ src/libsync/discoveryphase.cpp | 5 +++++ src/libsync/discoveryphase.h | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 4326295c93930..dd8fb5950fd1d 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -1666,6 +1666,9 @@ void ProcessDirectoryJob::processFileFinalize( ASSERT(_dirItem && _dirItem->_instruction == CSYNC_INSTRUCTION_RENAME); // This is because otherwise subitems are not updated! (ideally renaming a directory could // update the database for all items! See PropagateDirectory::slotSubJobsFinished) + auto adjustedOriginalPath = _discoveryData->adjustRenamedPath(path._original, SyncFileItem::Down); + Q_UNUSED(adjustedOriginalPath) + _discoveryData->_renamedItemsLocal.insert(path._original, path._target); item->_instruction = CSYNC_INSTRUCTION_RENAME; item->_renameTarget = path._target; item->_direction = _dirItem->_direction; diff --git a/src/libsync/discoveryphase.cpp b/src/libsync/discoveryphase.cpp index 7ae2022841803..ce492d9726299 100644 --- a/src/libsync/discoveryphase.cpp +++ b/src/libsync/discoveryphase.cpp @@ -261,6 +261,11 @@ void DiscoveryPhase::setSelectiveSyncWhiteList(const QStringList &list) _selectiveSyncWhiteList.sort(); } +bool DiscoveryPhase::isRenamed(const QString &p) const +{ + return _renamedItemsLocal.contains(p) || _renamedItemsRemote.contains(p); +} + void DiscoveryPhase::scheduleMoreJobs() { auto limit = qMax(1, _syncOptions._parallelNetworkJobs); diff --git a/src/libsync/discoveryphase.h b/src/libsync/discoveryphase.h index ccad6bb92a361..4d6dcea40644f 100644 --- a/src/libsync/discoveryphase.h +++ b/src/libsync/discoveryphase.h @@ -256,7 +256,7 @@ class DiscoveryPhase : public QObject * Useful for avoiding processing of items that have already been claimed in * a rename (would otherwise be discovered as deletions). */ - [[nodiscard]] bool isRenamed(const QString &p) const { return _renamedItemsLocal.contains(p) || _renamedItemsRemote.contains(p); } + [[nodiscard]] bool isRenamed(const QString &p) const; int _currentlyActiveJobs = 0;