Skip to content

Commit

Permalink
fix missing tracking for some item rename operations
Browse files Browse the repository at this point in the history
will fix mishandling of rename of a single file to multiple places
during discovery

Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Mar 5, 2024
1 parent b35a260 commit 8f8646f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/libsync/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions src/libsync/discoveryphase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ void DiscoveryPhase::setSelectiveSyncWhiteList(const QStringList &list)
_selectiveSyncWhiteList.sort();
}

bool DiscoveryPhase::isRenamed(const QString &p) const

Check warning on line 264 in src/libsync/discoveryphase.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/discoveryphase.cpp:264:22 [modernize-use-trailing-return-type]

use a trailing return type for this function

Check warning on line 264 in src/libsync/discoveryphase.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/discoveryphase.cpp:264:47 [readability-identifier-length]

parameter name 'p' is too short, expected at least 3 characters
{
return _renamedItemsLocal.contains(p) || _renamedItemsRemote.contains(p);
}

void DiscoveryPhase::scheduleMoreJobs()

Check warning on line 269 in src/libsync/discoveryphase.cpp

View workflow job for this annotation

GitHub Actions / build

src/libsync/discoveryphase.cpp:269:22 [readability-convert-member-functions-to-static]

method 'scheduleMoreJobs' can be made static
{
auto limit = qMax(1, _syncOptions._parallelNetworkJobs);
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/discoveryphase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 8f8646f

Please sign in to comment.