Skip to content

Commit

Permalink
Fix #3144: check for promptDeleteAllFiles config setting before emitt…
Browse files Browse the repository at this point in the history
…ing signal to display warning.

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 <[email protected]>
  • Loading branch information
camilasan committed Jun 4, 2024
1 parent e60f6b0 commit 11b11c0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
8 changes: 1 addition & 7 deletions src/gui/folder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions src/libsync/syncengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ 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) {
Expand All @@ -907,15 +907,14 @@ void SyncEngine::slotDiscoveryFinished()
}
}

QPointer<QObject> guard = new QObject();
QPointer<QObject> self = this;
const auto guard = new QObject();
const auto self = this;
auto callback = [this, self, finish, guard](bool cancel) -> void {
// use a guard to ensure its only called once...
// qpointer to self to ensure we still exist
if (!guard || !self) {
return;
}
guard->deleteLater();
if (cancel) {
qCInfo(lcEngine) << "User aborted sync";
finalize(false);
Expand Down

0 comments on commit 11b11c0

Please sign in to comment.