Skip to content

Commit

Permalink
Optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopheLarchier committed Oct 14, 2024
1 parent 3e46fa4 commit 177a0fe
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -488,22 +488,20 @@ bool Snapshot::checkIntegrityRecursively() {

bool Snapshot::checkIntegrityRecursively(const NodeId &parentId) {
// Check that we do not have the same file twice in the same folder
const auto &parrentItem = _items[parentId];
for (auto child = parrentItem.childrenIds().begin(), end = parrentItem.childrenIds().end(); child != end; child++) {
if (!checkIntegrityRecursively(*child)) {
const auto &parentItem = _items[parentId];
std::set<SyncName> names;
for (auto childId = parentItem.childrenIds().begin(), end = parentItem.childrenIds().end(); childId != end; childId++) {
if (!checkIntegrityRecursively(*childId)) {
return false;
}

for (auto child2 = child; child2 != end; ++child2) {
if (*child != *child2 && _items[*child].name() == _items[*child2].name()) {
LOG_ERROR(Log::instance()->getLogger(), "Snapshot integrity check failed, the folder named: \""
<< SyncName2Str(parrentItem.name()).c_str() << "\"("
<< parrentItem.id().c_str() << ") contains: \""
<< SyncName2Str(_items[*child].name()).c_str()
<< "\" twice with two differents NodeId (" << child->c_str()
<< " and " << child2->c_str() << ")");
return false;
}
auto result = names.insert(_items[*childId].name());
if (!result.second) {
LOG_ERROR(Log::instance()->getLogger(),
"Snapshot integrity check failed, the folder named: \""
<< SyncName2Str(parentItem.name()).c_str() << "\"(" << parentItem.id().c_str() << ") contains: \""
<< SyncName2Str(_items[*childId].name()).c_str() << "\" twice with two differents NodeId");
return false;
}
}
return true;
Expand Down

0 comments on commit 177a0fe

Please sign in to comment.