Fix tests failure. Refactoring.
authoralex-z <blackslayer4@gmail.com>
Mon, 22 Apr 2024 19:44:49 +0000 (21:44 +0200)
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>
Tue, 23 Apr 2024 10:18:40 +0000 (10:18 +0000)
Signed-off-by: alex-z <blackslayer4@gmail.com>
src/libsync/discovery.cpp
test/testsyncengine.cpp

index 60840911beab9b5646ca76dffee282bf6679d6be..387633c73f54ce8f1fc73b6e72f316bb2f3dc169 100644 (file)
@@ -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;
index 59b41ffc46010b31c212fe3af344b879b51abf53..0d2038e5f364f8ea09e109e6e2f254fdc1200d2a 100644 (file)
@@ -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");