Fix #3144: check for promptDeleteAllFiles config setting before emitting signal to...
authorCamila Ayres <hello@camilasan.com>
Tue, 4 Jun 2024 18:30:32 +0000 (20:30 +0200)
committerMatthieu Gallien <matthieu_gallien@yahoo.fr>
Fri, 28 Jun 2024 16:33:39 +0000 (18:33 +0200)
The signal is not connected to any slot when running nextcloudcmd.
The callback to finish the sync was never being called because the check for the config was done in the slot,
which was never called.

Signed-off-by: Camila Ayres <hello@camilasan.com>
src/gui/folder.cpp
src/libsync/syncengine.cpp

index d7c5fbac54bc957611f10e36be075b1fd364b007..69810631188f5a19a270dd77896f51c450c20581 100644 (file)
@@ -1628,12 +1628,6 @@ bool Folder::virtualFilesEnabled() const
 
 void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction dir, std::function<void(bool)> callback)
 {
-    ConfigFile cfgFile;
-    if (!cfgFile.promptDeleteFiles()) {
-        callback(false);
-        return;
-    }
-
     const QString msg = dir == SyncFileItem::Down ? tr("All files in the sync folder \"%1\" folder were deleted on the server.\n"
                                                  "These deletes will be synchronized to your local sync folder, making such files "
                                                  "unavailable unless you have a right to restore. \n"
@@ -1644,7 +1638,7 @@ void Folder::slotAboutToRemoveAllFiles(SyncFileItem::Direction dir, std::functio
                                                  "Are you sure you want to sync those actions with the server?\n"
                                                  "If this was an accident and you decide to keep your files, they will be re-synced from the server.");
     auto msgBox = new QMessageBox(QMessageBox::Warning, tr("Remove All Files?"),
-        msg.arg(shortGuiLocalPath()), QMessageBox::NoButton);
+    msg.arg(shortGuiLocalPath()), QMessageBox::NoButton);
     msgBox->setAttribute(Qt::WA_DeleteOnClose);
     msgBox->setWindowFlags(msgBox->windowFlags() | Qt::WindowStaysOnTopHint);
     msgBox->addButton(tr("Remove all files"), QMessageBox::DestructiveRole);
index 8f8dcecec31ca0f92fa993d510245ebbf5b975ca..2ce9966d889b4e7bf94daaf7a0ecfa800ec9fcc1 100644 (file)
@@ -898,10 +898,10 @@ void SyncEngine::slotDiscoveryFinished()
         qCInfo(lcEngine) << "#### Post-Reconcile end #################################################### " << _stopWatch.addLapTime(QStringLiteral("Post-Reconcile Finished")) << "ms";
     };
 
-    if (!_hasNoneFiles && _hasRemoveFile) {
+    if (!_hasNoneFiles && _hasRemoveFile && ConfigFile().promptDeleteFiles()) {
         qCInfo(lcEngine) << "All the files are going to be changed, asking the user";
         int side = 0; // > 0 means more deleted on the server.  < 0 means more deleted on the client
-        foreach (const auto &it, _syncItems) {
+        for (const auto &it : _syncItems) {
             if (it->_instruction == CSYNC_INSTRUCTION_REMOVE) {
                 side += it->_direction == SyncFileItem::Down ? 1 : -1;
             }