From 15b7385d1ad41bf0b807eb4c6ea655ae87474390 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Kunz?= Date: Fri, 15 Nov 2024 16:21:10 +0100 Subject: [PATCH 1/7] KDESKTOP-1384 - Differenciate events Move from MoveOut --- src/libcommon/utility/types.cpp | 2 ++ src/libcommon/utility/types.h | 2 +- .../file_system_observer/folderwatcher_win.cpp | 12 ++++-------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/libcommon/utility/types.cpp b/src/libcommon/utility/types.cpp index 233421b87..9a6530ea9 100644 --- a/src/libcommon/utility/types.cpp +++ b/src/libcommon/utility/types.cpp @@ -70,6 +70,8 @@ std::string toString(const OperationType e) { return "Delete"; case OperationType::Rights: return "Rights"; + case OperationType::MoveOut: + return "MoveOut"; default: return noConversionStr; } diff --git a/src/libcommon/utility/types.h b/src/libcommon/utility/types.h index 5c4fc95c8..e23a161f0 100644 --- a/src/libcommon/utility/types.h +++ b/src/libcommon/utility/types.h @@ -168,7 +168,7 @@ enum class NodeType { }; std::string toString(NodeType e); -enum class OperationType { None = 0x00, Create = 0x01, Move = 0x02, Edit = 0x04, Delete = 0x08, Rights = 0x10 }; +enum class OperationType { None = 0x00, Create = 0x01, Move = 0x02, Edit = 0x04, Delete = 0x08, Rights = 0x10, MoveOut = 0x20 }; std::string toString(OperationType e); enum class ExitCode { diff --git a/src/libsyncengine/update_detection/file_system_observer/folderwatcher_win.cpp b/src/libsyncengine/update_detection/file_system_observer/folderwatcher_win.cpp index 99da64c60..207fedd79 100644 --- a/src/libsyncengine/update_detection/file_system_observer/folderwatcher_win.cpp +++ b/src/libsyncengine/update_detection/file_system_observer/folderwatcher_win.cpp @@ -118,8 +118,7 @@ void FolderWatcher_win::watchChanges() { _ready = true; HANDLE handles[] = {_resultEventHandle, _stopEventHandle}; - DWORD result = WaitForMultipleObjects(2, handles, false // awake once one of them arrives - , + DWORD result = WaitForMultipleObjects(2, handles, false, // awake once one of them arrives INFINITE); if (result == 1) { @@ -180,6 +179,8 @@ void FolderWatcher_win::watchChanges() { << L" detected on item with " << Utility::formatSyncPath(longfilepath)); } + if (opType == OperationType::MoveOut) opType = OperationType::Move; // "MoveOut" is considered as Move from now on + changeDetected(longfilepath, opType); } @@ -213,20 +214,15 @@ void FolderWatcher_win::closeHandle() { OperationType FolderWatcher_win::operationFromAction(DWORD action) { switch (action) { case FILE_ACTION_RENAMED_OLD_NAME: - return OperationType::Move; - break; + return OperationType::MoveOut; case FILE_ACTION_RENAMED_NEW_NAME: return OperationType::Move; - break; case FILE_ACTION_ADDED: return OperationType::Create; - break; case FILE_ACTION_REMOVED: return OperationType::Delete; - break; case FILE_ACTION_MODIFIED: return OperationType::Edit; - break; } return OperationType::None; From 906eb6fdcdc9160d63633799ce763ba7aaf68a01 Mon Sep 17 00:00:00 2001 From: Herve Eruam Date: Mon, 18 Nov 2024 11:15:55 +0100 Subject: [PATCH 2/7] Add unit test for duplicate insertion in snapshot. --- .../file_system_observer/testsnapshot.cpp | 19 +++++++++++++++++++ .../file_system_observer/testsnapshot.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/test/libsyncengine/update_detection/file_system_observer/testsnapshot.cpp b/test/libsyncengine/update_detection/file_system_observer/testsnapshot.cpp index 78f3c2450..2885c91d8 100644 --- a/test/libsyncengine/update_detection/file_system_observer/testsnapshot.cpp +++ b/test/libsyncengine/update_detection/file_system_observer/testsnapshot.cpp @@ -117,6 +117,25 @@ void TestSnapshot::testSnapshot() { CPPUNIT_ASSERT_EQUAL(static_cast(1), snapshot.nbItems()); } +void TestSnapshot::testDuplicatedItem() { + const NodeId rootNodeId = *SyncDb::driveRootNode().nodeIdLocal(); + + const DbNode dummyRootNode(0, std::nullopt, Str("Local Drive"), SyncName(), "1", "1", std::nullopt, std::nullopt, + std::nullopt, NodeType::Directory, 0, std::nullopt); + Snapshot snapshot(ReplicaSide::Local, dummyRootNode); + + const SnapshotItem file1("A", rootNodeId, Str("file1"), 1640995201, -1640995201, NodeType::File, 123, + false, true, true); + const SnapshotItem file2("B", rootNodeId, Str("file1"), 1640995201, -1640995201, NodeType::File, 123, + false, true, true); + + snapshot.updateItem(file1); + snapshot.updateItem(file2); + + CPPUNIT_ASSERT(!snapshot.exists("A")); + CPPUNIT_ASSERT(snapshot.exists("B")); +} + void TestSnapshot::testSnapshotInsertionWithDifferentEncodings() { const NodeId rootNodeId = *SyncDb::driveRootNode().nodeIdLocal(); diff --git a/test/libsyncengine/update_detection/file_system_observer/testsnapshot.h b/test/libsyncengine/update_detection/file_system_observer/testsnapshot.h index c0365b400..a21d64d83 100644 --- a/test/libsyncengine/update_detection/file_system_observer/testsnapshot.h +++ b/test/libsyncengine/update_detection/file_system_observer/testsnapshot.h @@ -28,6 +28,7 @@ namespace KDC { class TestSnapshot : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TestSnapshot); CPPUNIT_TEST(testSnapshot); + CPPUNIT_TEST(testDuplicatedItem); CPPUNIT_TEST(testSnapshotInsertionWithDifferentEncodings); CPPUNIT_TEST_SUITE_END(); @@ -37,6 +38,7 @@ class TestSnapshot : public CppUnit::TestFixture { private: void testSnapshot(); + void testDuplicatedItem(); void testSnapshotInsertionWithDifferentEncodings(); }; From 1678281bfeae5635e073aa52ff944f5bba6a46d7 Mon Sep 17 00:00:00 2001 From: Herve Eruam Date: Mon, 18 Nov 2024 13:00:31 +0100 Subject: [PATCH 3/7] Add LFSO test for MS office. --- .../localfilesystemobserverworker.h | 2 +- .../testlocalfilesystemobserverworker.cpp | 34 +++++++++++++++--- .../testlocalfilesystemobserverworker.h | 36 ++++++++++++++++--- 3 files changed, 63 insertions(+), 9 deletions(-) diff --git a/src/libsyncengine/update_detection/file_system_observer/localfilesystemobserverworker.h b/src/libsyncengine/update_detection/file_system_observer/localfilesystemobserverworker.h index 0fd2c313a..643424439 100644 --- a/src/libsyncengine/update_detection/file_system_observer/localfilesystemobserverworker.h +++ b/src/libsyncengine/update_detection/file_system_observer/localfilesystemobserverworker.h @@ -32,7 +32,7 @@ class LocalFileSystemObserverWorker : public FileSystemObserverWorker { void start() override; void stop() override; - void changesDetected(const std::list> &changes); + virtual void changesDetected(const std::list> &changes); virtual void forceUpdate() override; protected: diff --git a/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.cpp b/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.cpp index 3d65ac1c6..4362479d8 100644 --- a/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.cpp +++ b/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.cpp @@ -408,19 +408,45 @@ void TestLocalFileSystemObserverWorker::testLFSOWithSpecialCases2() { CPPUNIT_ASSERT(_syncPal->snapshot(ReplicaSide::Local)->name(initItemId) == testFilename); } -void TestLocalFileSystemObserverWorker::testLFSOFastMoveDelete() { +void TestLocalFileSystemObserverWorker::testLFSOFastMoveDeleteMove() { // MS Office test LOGW_DEBUG(_logger, L"***** Test fast move/delete *****"); + _syncPal->_localFSObserverWorker->stop(); + _syncPal->_localFSObserverWorker.reset(); + + // Create a slow observer +#if defined(_WIN32) + _syncPal->_localFSObserverWorker = + std::make_shared(_syncPal, "Local File System Observer", "LFSO"); +#else + _syncPal->_localFSObserverWorker = + std::make_shared(_syncPal, "Local File System Observer", "LFSO"); +#endif + _syncPal->_localFSObserverWorker->start(); + + int count = 0; + while (!_syncPal->snapshot(ReplicaSide::Local)->isValid()) { // Wait for the snapshot generation + Utility::msleep(100); + CPPUNIT_ASSERT(count++ < 20); // Do not wait more than 2s + } + CPPUNIT_ASSERT(_syncPal->snapshot(ReplicaSide::Local)->exists(_testFiles[0].first)); IoError ioError = IoError::Unknown; SyncPath destinationPath = _testFiles[0].second.parent_path() / (_testFiles[0].second.filename().string() + "2"); - CPPUNIT_ASSERT(IoHelper::renameItem(_testFiles[0].second, destinationPath, ioError)); + CPPUNIT_ASSERT(IoHelper::renameItem(_testFiles[0].second, destinationPath, ioError)); // test0.txt -> test0.txt2 + CPPUNIT_ASSERT_EQUAL(IoError::Success, ioError); + CPPUNIT_ASSERT(IoHelper::deleteItem(destinationPath, ioError)); // Delete test0.txt2 (before the previous rename is processed) CPPUNIT_ASSERT_EQUAL(IoError::Success, ioError); - CPPUNIT_ASSERT(IoHelper::deleteItem(destinationPath, ioError)); + CPPUNIT_ASSERT(IoHelper::renameItem(_testFiles[1].second, _testFiles[0].second, + ioError)); // test1.txt -> test0.txt (before the previous rename and delete is processed) CPPUNIT_ASSERT_EQUAL(IoError::Success, ioError); + Utility::msleep(1000); // Wait 1sec for the slow observer to process the events (+-200ms per event). - Utility::msleep(1000); // Wait 1sec + FileStat fileStat; + CPPUNIT_ASSERT(IoHelper::getFileStat(_testFiles[0].second, &fileStat, ioError)); + CPPUNIT_ASSERT_EQUAL(IoError::Success, ioError); CPPUNIT_ASSERT(!_syncPal->snapshot(ReplicaSide::Local)->exists(_testFiles[0].first)); + CPPUNIT_ASSERT(_syncPal->snapshot(ReplicaSide::Local)->exists(std::to_string(fileStat.inode))); } } // namespace KDC diff --git a/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.h b/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.h index d9f6d3ce9..e953ede7a 100644 --- a/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.h +++ b/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.h @@ -20,9 +20,12 @@ #include "testincludes.h" #include "test_utility/localtemporarydirectory.h" - #include "syncpal/syncpal.h" - +#if defined(_WIN32) +#include "libsyncengine/update_detection/file_system_observer/localfilesystemobserverworker_win.h" +#else +#include "libsyncengine/update_detection/file_system_observer/localfilesystemobserverworker_unix.h" +#endif #include using namespace CppUnit; @@ -30,6 +33,31 @@ using namespace CppUnit; namespace KDC { class LocalFileSystemObserverWorker; +#if defined(_WIN32) +class MockLocalFileSystemObserverWorker_win : public LocalFileSystemObserverWorker_win { + public: + MockLocalFileSystemObserverWorker_win(std::shared_ptr syncPal, const std::string &name, + const std::string &shortName) : + LocalFileSystemObserverWorker_win(syncPal, name, shortName) {} + + void changesDetected(const std::list> &changes) final { + Utility::msleep(200); + LocalFileSystemObserverWorker_win::changesDetected(changes); + } +}; +#else +class MockLocalFileSystemObserverWorker_unix : public LocalFileSystemObserverWorker_unix { + public: + MockLocalFileSystemObserverWorker_unix(std::shared_ptr syncPal, const std::string &name, + const std::string &shortName) : + LocalFileSystemObserverWorker_unix(syncPal, name, shortName) {} + + void changesDetected(const std::list> &changes) final { + Utility::msleep(200); + LocalFileSystemObserverWorker_unix::changesDetected(changes); + } +}; +#endif class TestLocalFileSystemObserverWorker : public CppUnit::TestFixture { CPPUNIT_TEST_SUITE(TestLocalFileSystemObserverWorker); @@ -38,7 +66,7 @@ class TestLocalFileSystemObserverWorker : public CppUnit::TestFixture { CPPUNIT_TEST(testLFSOWithDuplicateFileNames); CPPUNIT_TEST(testLFSODeleteDir); CPPUNIT_TEST(testLFSOWithDirs); - CPPUNIT_TEST(testLFSOFastMoveDelete); + CPPUNIT_TEST(testLFSOFastMoveDeleteMove); CPPUNIT_TEST(testLFSOWithSpecialCases1); CPPUNIT_TEST(testLFSOWithSpecialCases2); CPPUNIT_TEST_SUITE_END(); @@ -61,7 +89,7 @@ class TestLocalFileSystemObserverWorker : public CppUnit::TestFixture { void testLFSOWithDuplicateFileNames(); void testLFSOWithDirs(); void testLFSODeleteDir(); - void testLFSOFastMoveDelete(); + void testLFSOFastMoveDeleteMove(); void testLFSOWithSpecialCases1(); void testLFSOWithSpecialCases2(); }; From 6e2c56b800be7303a4148b20cf10b9f27fd0c70c Mon Sep 17 00:00:00 2001 From: Herve Eruam Date: Mon, 18 Nov 2024 13:01:13 +0100 Subject: [PATCH 4/7] Check for item dupliacation in Snapshot::updateItem --- .../snapshot/snapshot.cpp | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp index 23509e9e2..9bb147e6b 100644 --- a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp +++ b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp @@ -77,6 +77,27 @@ bool Snapshot::updateItem(const SnapshotItem &newItem) { return false; } + // Check if the item already exists in the new parent + if (auto itNewParent = _items.find(newItem.parentId()); itNewParent != _items.end()) { + auto childrenIds = itNewParent->second.childrenIds(); // Copy to avoid iterator invalidation + for (const NodeId &childId: childrenIds) { + auto child = _items.find(childId); + if (child == _items.end()) { + assert(false && "Child not found in snapshot"); + LOG_WARN(Log::instance()->getLogger(), "Child " << childId.c_str() << " not found in snapshot"); + continue; + } + + if (child->second.name() == newItem.name() && child->second.id() != newItem.id()) { + LOGW_DEBUG(Log::instance()->getLogger(), + L"Item: " << SyncName2WStr(newItem.name()) << L" (" << Utility::s2ws(newItem.id()) + << L") already exists in parent: " << Utility::s2ws(newItem.parentId()) + << L" with a different id. Removing it and adding the new one."); + removeItem(childId); + } + } + } + const SnapshotItem &prevItem = _items[newItem.id()]; // Update parent's children lists From 56a5eccaac8e1edbf8c51cd51050a2fabd3366ec Mon Sep 17 00:00:00 2001 From: Herve Eruam Date: Mon, 18 Nov 2024 13:09:36 +0100 Subject: [PATCH 5/7] Time optimisation of duplicate item check. --- .../file_system_observer/snapshot/snapshot.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp index 9bb147e6b..482a4d42d 100644 --- a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp +++ b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp @@ -79,8 +79,7 @@ bool Snapshot::updateItem(const SnapshotItem &newItem) { // Check if the item already exists in the new parent if (auto itNewParent = _items.find(newItem.parentId()); itNewParent != _items.end()) { - auto childrenIds = itNewParent->second.childrenIds(); // Copy to avoid iterator invalidation - for (const NodeId &childId: childrenIds) { + for (const NodeId &childId: itNewParent->second.childrenIds()) { auto child = _items.find(childId); if (child == _items.end()) { assert(false && "Child not found in snapshot"); @@ -94,8 +93,10 @@ bool Snapshot::updateItem(const SnapshotItem &newItem) { << L") already exists in parent: " << Utility::s2ws(newItem.parentId()) << L" with a different id. Removing it and adding the new one."); removeItem(childId); + break; // There should be (at most) only one item with the same name in a folder } } + } const SnapshotItem &prevItem = _items[newItem.id()]; From 64d66e7bf97265fce9c4511acf35bb87d0bdd3a5 Mon Sep 17 00:00:00 2001 From: Herve Eruam Date: Mon, 18 Nov 2024 14:44:23 +0100 Subject: [PATCH 6/7] Fix tests on mac and linux. --- .../snapshot/snapshot.cpp | 2 +- .../file_system_observer/snapshot/snapshot.h | 2 +- .../testlocalfilesystemobserverworker.cpp | 24 ++++++++++++------- .../testlocalfilesystemobserverworker.h | 15 +++++++----- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp index 482a4d42d..e1e9ccc28 100644 --- a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp +++ b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp @@ -140,7 +140,7 @@ bool Snapshot::updateItem(const SnapshotItem &newItem) { return true; } -bool Snapshot::removeItem(const NodeId &id) { +bool Snapshot::removeItem(const NodeId id) { const std::scoped_lock lock(_mutex); if (id.empty()) { diff --git a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.h b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.h index 311a9eaa6..21e2aa711 100644 --- a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.h +++ b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.h @@ -40,7 +40,7 @@ class Snapshot : public SharedObject { void init(); bool updateItem(const SnapshotItem &newItem); - bool removeItem(const NodeId &id); + bool removeItem(const NodeId id); // Do not pass by reference to avoid dangling references NodeId itemId(const SyncPath &path) const; NodeId parentId(const NodeId &itemId) const; diff --git a/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.cpp b/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.cpp index 4362479d8..d4a00b582 100644 --- a/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.cpp +++ b/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.cpp @@ -414,13 +414,8 @@ void TestLocalFileSystemObserverWorker::testLFSOFastMoveDeleteMove() { // MS Off _syncPal->_localFSObserverWorker.reset(); // Create a slow observer -#if defined(_WIN32) - _syncPal->_localFSObserverWorker = - std::make_shared(_syncPal, "Local File System Observer", "LFSO"); -#else - _syncPal->_localFSObserverWorker = - std::make_shared(_syncPal, "Local File System Observer", "LFSO"); -#endif + auto slowObserver = std::make_shared(_syncPal, "Local File System Observer", "LFSO"); + _syncPal->_localFSObserverWorker = slowObserver; _syncPal->_localFSObserverWorker->start(); int count = 0; @@ -439,7 +434,8 @@ void TestLocalFileSystemObserverWorker::testLFSOFastMoveDeleteMove() { // MS Off CPPUNIT_ASSERT(IoHelper::renameItem(_testFiles[1].second, _testFiles[0].second, ioError)); // test1.txt -> test0.txt (before the previous rename and delete is processed) CPPUNIT_ASSERT_EQUAL(IoError::Success, ioError); - Utility::msleep(1000); // Wait 1sec for the slow observer to process the events (+-200ms per event). + + CPPUNIT_ASSERT_MESSAGE("No update detected in the expected time.", slowObserver->waitForUpdate()); FileStat fileStat; CPPUNIT_ASSERT(IoHelper::getFileStat(_testFiles[0].second, &fileStat, ioError)); @@ -449,4 +445,16 @@ void TestLocalFileSystemObserverWorker::testLFSOFastMoveDeleteMove() { // MS Off CPPUNIT_ASSERT(_syncPal->snapshot(ReplicaSide::Local)->exists(std::to_string(fileStat.inode))); } +bool MockLocalFileSystemObserverWorker::waitForUpdate(uint64_t timeoutMs) const { + using namespace std::chrono; + auto start = system_clock::now(); + while (!_updating && duration_cast(system_clock::now() - start).count() < timeoutMs) { + Utility::msleep(10); + } + while (_updating && duration_cast(system_clock::now() - start).count() < timeoutMs) { + Utility::msleep(10); + } + return duration_cast(system_clock::now() - start).count() < timeoutMs; +} + } // namespace KDC diff --git a/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.h b/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.h index e953ede7a..b0a55b521 100644 --- a/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.h +++ b/test/libsyncengine/update_detection/file_system_observer/testlocalfilesystemobserverworker.h @@ -34,28 +34,31 @@ namespace KDC { class LocalFileSystemObserverWorker; #if defined(_WIN32) -class MockLocalFileSystemObserverWorker_win : public LocalFileSystemObserverWorker_win { +class MockLocalFileSystemObserverWorker : public LocalFileSystemObserverWorker_win { public: - MockLocalFileSystemObserverWorker_win(std::shared_ptr syncPal, const std::string &name, - const std::string &shortName) : + MockLocalFileSystemObserverWorker(std::shared_ptr syncPal, const std::string &name, + const std::string &shortName) : LocalFileSystemObserverWorker_win(syncPal, name, shortName) {} void changesDetected(const std::list> &changes) final { Utility::msleep(200); LocalFileSystemObserverWorker_win::changesDetected(changes); } + + bool waitForUpdate(uint64_t timeoutMs = 100000) const; }; #else -class MockLocalFileSystemObserverWorker_unix : public LocalFileSystemObserverWorker_unix { +class MockLocalFileSystemObserverWorker : public LocalFileSystemObserverWorker_unix { public: - MockLocalFileSystemObserverWorker_unix(std::shared_ptr syncPal, const std::string &name, - const std::string &shortName) : + MockLocalFileSystemObserverWorker(std::shared_ptr syncPal, const std::string &name, + const std::string &shortName) : LocalFileSystemObserverWorker_unix(syncPal, name, shortName) {} void changesDetected(const std::list> &changes) final { Utility::msleep(200); LocalFileSystemObserverWorker_unix::changesDetected(changes); } + bool waitForUpdate(uint64_t timeoutMs = 100000) const; }; #endif From 407bfd87b236e3bf27b05a35738af225e37fd1b2 Mon Sep 17 00:00:00 2001 From: Herve Eruam Date: Mon, 18 Nov 2024 14:51:31 +0100 Subject: [PATCH 7/7] Comment enhancement. --- .../update_detection/file_system_observer/snapshot/snapshot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp index e1e9ccc28..5c5814a8b 100644 --- a/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp +++ b/src/libsyncengine/update_detection/file_system_observer/snapshot/snapshot.cpp @@ -77,7 +77,7 @@ bool Snapshot::updateItem(const SnapshotItem &newItem) { return false; } - // Check if the item already exists in the new parent + // Check if `newItem` already exists with the same path but a different Id if (auto itNewParent = _items.find(newItem.parentId()); itNewParent != _items.end()) { for (const NodeId &childId: itNewParent->second.childrenIds()) { auto child = _items.find(childId);