fix failing automated test that erases invalid iterator

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2023-09-17 11:09:02 +02:00 committed by Matthieu Gallien
parent ced85ac287
commit 274d866c19
2 changed files with 8 additions and 4 deletions

View file

@ -159,8 +159,13 @@ void FileInfo::remove(const QString &relativePath)
const PathComponents pathComponents { relativePath };
FileInfo *parent = findInvalidatingEtags(pathComponents.parentDirComponents());
Q_ASSERT(parent);
parent->children.erase(std::find_if(parent->children.begin(), parent->children.end(),
[&pathComponents](const FileInfo &fi) { return fi.name == pathComponents.fileName(); }));
auto childrenIt = std::find_if(parent->children.begin(), parent->children.end(),
[&pathComponents](const FileInfo &fi) {
return fi.name == pathComponents.fileName();
});
if (childrenIt != parent->children.end()) {
parent->children.erase(childrenIt);
}
}
void FileInfo::insert(const QString &relativePath, qint64 size, char contentChar)

View file

@ -1700,8 +1700,7 @@ private slots:
conflicts = findCaseClashConflicts(fakeFolder.currentLocalState());
QCOMPARE(conflicts.size(), 0);
// remove both files from the server(lower and UPPER case)
fakeFolder.remoteModifier().remove(testLowerCaseFile);
// remove the other file
fakeFolder.remoteModifier().remove(testUpperCaseFile);
QVERIFY(fakeFolder.syncOnce());
}