mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
[Oracle] Don't report a cancelled card database update as successful (#7082)
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 cover (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 26 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Desktop / Prune caches (push) Waiting to run
Build Docker / Servatrice (arm) (push) Waiting to run
Build Docker / Servatrice (x86) (push) Waiting to run
Build Docker / Publish multi-platform Servatrice image (push) Blocked by required conditions
Some checks are pending
CodeQL / Analyze (cpp) (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
Build Desktop / Configure (push) Waiting to run
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 44 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 (push) Blocked by required conditions
Build Desktop / Arch (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 cover (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (push) Blocked by required conditions
Build Desktop / macOS 14 (push) Blocked by required conditions
Build Desktop / macOS 15 (push) Blocked by required conditions
Build Desktop / macOS 26 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Desktop / Prune caches (push) Waiting to run
Build Docker / Servatrice (arm) (push) Waiting to run
Build Docker / Servatrice (x86) (push) Waiting to run
Build Docker / Publish multi-platform Servatrice image (push) Blocked by required conditions
* [Oracle] Don't report a cancelled card database update as successful (#3470) Took 3 minutes * [Oracle] Only report cancel when nothing was saved yet Rejecting the wizard after SaveSetsPage or a download page already wrote the database to disk still replaced cards.xml on disk, but wasCancelled() forced exit code 1 so Cockatrice skipped the reload. Track successful saves with OracleWizard::markDatabaseSaved() and only treat a cancel as a failure when nothing was saved. * [Oracle] Restore updater stderr in card update error dialog --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
bbf0425655
commit
96b0888a73
7 changed files with 50 additions and 10 deletions
|
|
@ -85,5 +85,8 @@ int main(int argc, char *argv[])
|
|||
QTimer::singleShot(0, &wizard, [&wizard]() { wizard.runInBackground(); });
|
||||
}
|
||||
|
||||
return app.exec();
|
||||
const int execResult = app.exec();
|
||||
// A cancel only counts when nothing was written yet: closing the wizard
|
||||
// after the card database was already saved on disk is still an update.
|
||||
return (wizard.wasCancelled() && !wizard.hasSavedDatabase()) ? 1 : execResult;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,12 +128,20 @@ void OracleWizard::accept()
|
|||
|
||||
void OracleWizard::reject()
|
||||
{
|
||||
cancelled = true;
|
||||
|
||||
// The wizard is being closed while a page may still run a worker on the
|
||||
// importer. Ask it to stop before the wizard (and the importer child) is
|
||||
// destroyed, so the worker thread never touches freed memory.
|
||||
if (auto *active = dynamic_cast<OracleWizardPage *>(currentPage())) {
|
||||
active->cancelWork();
|
||||
}
|
||||
|
||||
const auto replies = nam->findChildren<QNetworkReply *>();
|
||||
for (QNetworkReply *reply : replies) {
|
||||
reply->abort();
|
||||
}
|
||||
|
||||
QWizard::reject();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,6 +20,19 @@ public:
|
|||
explicit OracleWizard(QWidget *parent = nullptr);
|
||||
void accept() override;
|
||||
void reject() override;
|
||||
bool wasCancelled()
|
||||
{
|
||||
return cancelled;
|
||||
}
|
||||
/** @brief Records that the card database was written to disk, so a later cancel still counts as an update. */
|
||||
void markDatabaseSaved()
|
||||
{
|
||||
databaseSaved = true;
|
||||
}
|
||||
bool hasSavedDatabase()
|
||||
{
|
||||
return databaseSaved;
|
||||
}
|
||||
void enableButtons();
|
||||
void disableButtons();
|
||||
void retranslateUi();
|
||||
|
|
@ -67,6 +80,8 @@ private:
|
|||
QByteArray tokensData;
|
||||
QString cardSourceUrl;
|
||||
QString cardSourceVersion;
|
||||
bool cancelled = false;
|
||||
bool databaseSaved = false;
|
||||
|
||||
void migrateOracleSettings();
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -484,6 +484,10 @@ void LoadSetsPage::actDownloadFinishedSetsFile()
|
|||
{
|
||||
// check for a reply
|
||||
auto *reply = dynamic_cast<QNetworkReply *>(sender());
|
||||
if (wizard()->wasCancelled()) {
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
auto errorCode = reply->error();
|
||||
if (errorCode != QNetworkReply::NoError) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
|
||||
|
|
@ -895,6 +899,7 @@ bool SaveSetsPage::validatePage()
|
|||
return false;
|
||||
}
|
||||
|
||||
wizard()->markDatabaseSaved();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -178,6 +178,10 @@ void SimpleDownloadFilePage::actDownloadFinished()
|
|||
{
|
||||
// check for a reply
|
||||
auto *reply = dynamic_cast<QNetworkReply *>(sender());
|
||||
if (wizard()->wasCancelled()) {
|
||||
reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
QNetworkReply::NetworkError errorCode = reply->error();
|
||||
if (errorCode != QNetworkReply::NoError) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
|
||||
|
|
@ -242,6 +246,7 @@ bool SimpleDownloadFilePage::saveToFile()
|
|||
|
||||
// clean saved downloadData
|
||||
downloadData = QByteArray();
|
||||
wizard()->markDatabaseSaved();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue