delete invalid folders and restart sync automatically
authorMatthieu Gallien <matthieu.gallien@nextcloud.com>
Mon, 2 Sep 2024 20:50:26 +0000 (22:50 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Thu, 12 Sep 2024 06:40:50 +0000 (08:40 +0200)
users should then notice that the sync errors are gone

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
src/gui/folder.cpp

index 52baa342f13b6c3fc2cd3a87a70718e168c94cd7..67de7b3874394d0af6c9154daf33bbc80fafb6f1 100644 (file)
@@ -1670,28 +1670,21 @@ void Folder::slotNeedToRemoveRemnantsReadOnlyFolders(const QList<SyncFileItemPtr
                                                      const QString &localPath,
                                                      std::function<void (bool)> callback)
 {
-    const auto msg = tr("Do you want to clean up remnant read-only folders left over from previous failed synchronization attempts.");
-    auto msgBox = new QMessageBox(QMessageBox::Question, tr("Remove remnant invalid folders?"),
-                                  msg, QMessageBox::NoButton);
-    msgBox->setAttribute(Qt::WA_DeleteOnClose);
-    msgBox->setWindowFlags(msgBox->windowFlags() | Qt::WindowStaysOnTopHint);
-    msgBox->addButton(tr("Proceed to remove remnant folders"), QMessageBox::AcceptRole);
-    const auto keepBtn = msgBox->addButton(tr("Do nothing"), QMessageBox::RejectRole);
+    auto listOfFolders = QStringList{};
+    for (const auto &oneFolder : folders) {
+        listOfFolders.push_back(oneFolder->_file);
+    }
+
+    qCInfo(lcFolder()) << "will delete invalid read-only folders:" << listOfFolders.join(", ");
+
     setSyncPaused(true);
-    connect(msgBox, &QMessageBox::finished, this, [msgBox, keepBtn, callback, folders, localPath, this] {
-        const bool cancel = msgBox->clickedButton() == keepBtn;
-        if (!cancel) {
-            for(const auto &oneFolder : folders) {
-                FileSystem::removeRecursively(localPath + oneFolder->_file);
-            }
-        }
-        callback(cancel);
-        if (cancel) {
-            setSyncPaused(true);
-        }
-    });
-    connect(this, &Folder::destroyed, msgBox, &QMessageBox::deleteLater);
-    msgBox->open();
+    for(const auto &oneFolder : folders) {
+        FileSystem::removeRecursively(localPath + oneFolder->_file);
+    }
+    callback(true);
+    setSyncPaused(false);
+    _lastEtag.clear();
+    slotScheduleThisFolder();
 }
 
 void Folder::removeLocalE2eFiles()