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 <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2024-03-05 12:09:45 +01:00
parent b35a26091b
commit b7c1a95d1c
No known key found for this signature in database
GPG key ID: 7D0F74F05C22F553
3 changed files with 9 additions and 1 deletions

View 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;

View 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);

View 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;