From: alex-z Date: Mon, 22 Apr 2024 19:44:49 +0000 (+0200) Subject: Fix tests failure. Refactoring. X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~12^2~7^2~43^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=005b0aabc4caa5a21d8eb9ff714e5d437704858e;p=nextcloud-desktop.git Fix tests failure. Refactoring. Signed-off-by: alex-z --- diff --git a/src/libsync/discovery.cpp b/src/libsync/discovery.cpp index 60840911b..387633c73 100644 --- a/src/libsync/discovery.cpp +++ b/src/libsync/discovery.cpp @@ -405,11 +405,8 @@ bool ProcessDirectoryJob::handleExcluded(const QString &path, const Entries &ent } if (_dirItem) { - if (item->_status == SyncFileItem::FileNameInvalid) { - _dirItem->_isAnyInvalidCharChild = true; - } else if (item->_status == SyncFileItem::FileNameClash) { - _dirItem->_isAnyCaseClashChild = true; - } + _dirItem->_isAnyInvalidCharChild = _dirItem->_isAnyInvalidCharChild || item->_status == SyncFileItem::FileNameInvalid; + _dirItem->_isAnyCaseClashChild = _dirItem->_isAnyCaseClashChild || item->_status == SyncFileItem::FileNameClash; } _childIgnored = true; diff --git a/test/testsyncengine.cpp b/test/testsyncengine.cpp index 59b41ffc4..0d2038e5f 100644 --- a/test/testsyncengine.cpp +++ b/test/testsyncengine.cpp @@ -1740,37 +1740,37 @@ private slots: #else constexpr auto shouldHaveCaseClashConflict = true; #endif + if (shouldHaveCaseClashConflict) { + ItemCompletedSpy completeSpy(fakeFolder); - ItemCompletedSpy completeSpy(fakeFolder); - - fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem); - QVERIFY(fakeFolder.syncOnce()); + fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem); + QVERIFY(fakeFolder.syncOnce()); - // verify the parent of a folder where caseclash and invalidchar conflicts were found, has corresponding flags set (conflict info must get propagated to the very top) - const auto diverseConflicttsFolderParent = completeSpy.findItem(conflictsFolderPathComponents.first()); - QVERIFY(diverseConflicttsFolderParent); - QVERIFY(diverseConflicttsFolderParent->_isAnyCaseClashChild); - QVERIFY(diverseConflicttsFolderParent->_isAnyInvalidCharChild); - completeSpy.clear(); + // verify the parent of a folder where caseclash and invalidchar conflicts were found, has corresponding flags set (conflict info must get + // propagated to the very top) + const auto diverseConflictsFolderParent = completeSpy.findItem(conflictsFolderPathComponents.first()); + QVERIFY(diverseConflictsFolderParent); + QVERIFY(diverseConflictsFolderParent->_isAnyCaseClashChild); + QVERIFY(diverseConflictsFolderParent->_isAnyInvalidCharChild); + completeSpy.clear(); - auto diverseConflictsFolderInfo = fakeFolder.currentLocalState().findRecursive(diverseConflictsFolderPath); - QVERIFY(!diverseConflictsFolderInfo.name.isEmpty()); + auto diverseConflictsFolderInfo = fakeFolder.currentLocalState().findRecursive(diverseConflictsFolderPath); + QVERIFY(!diverseConflictsFolderInfo.name.isEmpty()); - auto conflictsFile = findCaseClashConflicts(diverseConflictsFolderInfo); - QCOMPARE(conflictsFile.size(), shouldHaveCaseClashConflict ? 1 : 0); - const auto hasFileCaseClashConflict = expectConflict(diverseConflictsFolderInfo, testLowerCaseFile); - QCOMPARE(hasFileCaseClashConflict, shouldHaveCaseClashConflict ? true : false); + auto conflictsFile = findCaseClashConflicts(diverseConflictsFolderInfo); + QCOMPARE(conflictsFile.size(), shouldHaveCaseClashConflict ? 1 : 0); + const auto hasFileCaseClashConflict = expectConflict(diverseConflictsFolderInfo, testLowerCaseFile); + QCOMPARE(hasFileCaseClashConflict, shouldHaveCaseClashConflict ? true : false); - fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem); - QVERIFY(fakeFolder.syncOnce()); + fakeFolder.syncEngine().setLocalDiscoveryOptions(OCC::LocalDiscoveryStyle::DatabaseAndFilesystem); + QVERIFY(fakeFolder.syncOnce()); - diverseConflictsFolderInfo = fakeFolder.currentLocalState().findRecursive(diverseConflictsFolderPath); - QVERIFY(!diverseConflictsFolderInfo.name.isEmpty()); + diverseConflictsFolderInfo = fakeFolder.currentLocalState().findRecursive(diverseConflictsFolderPath); + QVERIFY(!diverseConflictsFolderInfo.name.isEmpty()); - conflictsFile = findCaseClashConflicts(diverseConflictsFolderInfo); - QCOMPARE(conflictsFile.size(), shouldHaveCaseClashConflict ? 1 : 0); + conflictsFile = findCaseClashConflicts(diverseConflictsFolderInfo); + QCOMPARE(conflictsFile.size(), shouldHaveCaseClashConflict ? 1 : 0); - if (shouldHaveCaseClashConflict) { const auto conflictFileName = QString{conflictsFile.constFirst()}; qDebug() << conflictFileName; CaseClashConflictSolver conflictSolver(fakeFolder.localPath() + diverseConflictsFolderPath + "/" + testLowerCaseFile, @@ -1809,8 +1809,9 @@ private slots: auto caseClashConflictFolderItemLower = completeSpy.findItem(diverseConflictsFolderPath + "/" + testLowerCaseFolder); auto caseClashConflictFolderItemUpper = completeSpy.findItem(diverseConflictsFolderPath + "/" + testUpperCaseFolder); completeSpy.clear(); - - // we always create UPPERCASE folder in current syncengine logic for now and then create a conflict for a lowercase folder, but this may change, so keep this check more future proof + + // we always create UPPERCASE folder in current syncengine logic for now and then create a conflict for a lowercase folder, but this may change, so + // keep this check more future proof const auto upperOrLowerCaseFolderCaseClashFound = (caseClashConflictFolderItemLower && caseClashConflictFolderItemLower->_status == SyncFileItem::FileNameClash) || (caseClashConflictFolderItemUpper && caseClashConflictFolderItemUpper->_status == SyncFileItem::FileNameClash); @@ -1819,11 +1820,11 @@ private slots: // solve case clash folders conflict CaseClashConflictSolver conflictSolverCaseClashForFolder(fakeFolder.localPath() + diverseConflictsFolderPath + "/" + testLowerCaseFolder, - fakeFolder.localPath() + diverseConflictsFolderPath + "/" + testUpperCaseFolder, - QStringLiteral("/"), - fakeFolder.localPath(), - fakeFolder.account(), - &fakeFolder.syncJournal()); + fakeFolder.localPath() + diverseConflictsFolderPath + "/" + testUpperCaseFolder, + QStringLiteral("/"), + fakeFolder.localPath(), + fakeFolder.account(), + &fakeFolder.syncJournal()); QSignalSpy conflictSolverCaseClashForFolderDone(&conflictSolverCaseClashForFolder, &CaseClashConflictSolver::done); conflictSolverCaseClashForFolder.solveConflict("testfolder1");