fix missing tracking for some item rename operations
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 5 Mar 2024 11:09:45 +0000 (12:09 +0100)
committerMatthieu Gallien <matthieu.gallien@nextcloud.com>
Tue, 5 Mar 2024 15:43:05 +0000 (16:43 +0100)
will fix mishandling of rename of a single file to multiple places
during discovery

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/libsync/discovery.cpp
src/libsync/discoveryphase.cpp
src/libsync/discoveryphase.h

index 4326295c9393037ac60d2f5176615bd7af460821..a9fb2d63b2f1478974efd565cdaddf068ef0cf92 100644 (file)
@@ -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)
+        const 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;
index 7ae2022841803ff482046017ea96f8d28b9efdc4..ce492d97262997dd05fea89cb3cd8a3d99d981a5 100644 (file)
@@ -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);
index ccad6bb92a361cc6ee6d5c831b95ef704d6ff3a1..4d6dcea40644fbcb97a74b3508d488f3e57c1865 100644 (file)
@@ -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;