mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-06 01:53:25 -08:00
Preserve installed card databases when Oracle refresh fails (#7739)
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 / vcpkg baseline (push) Waiting to run
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 sanitize (push) Blocked by required conditions
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Fedora 44 (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 / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 cover (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 27 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (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 / vcpkg baseline (push) Waiting to run
Build Desktop / Servatrice_Debian 12 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 sanitize (push) Blocked by required conditions
Build Desktop / Debian 13 (push) Blocked by required conditions
Build Desktop / Fedora 44 (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 / Debian 12 (push) Blocked by required conditions
Build Desktop / Fedora 43 (push) Blocked by required conditions
Build Desktop / Ubuntu 24.04 (push) Blocked by required conditions
Build Desktop / Ubuntu 26.04 cover (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 27 Debug (push) Blocked by required conditions
Build Desktop / Windows 10 (push) Blocked by required conditions
Build Desktop / macOS 13 Intel (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
* Preserve installed card databases when Oracle refresh fails * Fix the Oracle refresh verdict and cover the parser write path A background refresh that already installed cards.xml exited 1 when the token save afterwards failed, so the client kept its old in-memory database and reported the update as failed. Return the same verdict main() already computes: a reject after the database was written is a successful update. Cover the writer Oracle actually uses: add a short-write death test for CockatriceXml4Parser::saveToFile, which reverted to QFile would truncate an installed database without any test noticing. Route a failed background token download through reject() instead of a modal box on a hidden wizard, which left the client waiting with no timeout and blocked later updates. Test the first non-space byte in place rather than copying the payload, and report an import refusal with the importer's own message. --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
e558c0dffa
commit
3a656c9c4a
14 changed files with 517 additions and 72 deletions
|
|
@ -1,5 +1,6 @@
|
|||
#include "pagetemplates.h"
|
||||
|
||||
#include "database_writer.h"
|
||||
#include "oraclewizard.h"
|
||||
|
||||
#include <QCheckBox>
|
||||
|
|
@ -184,9 +185,17 @@ void SimpleDownloadFilePage::actDownloadFinished()
|
|||
}
|
||||
QNetworkReply::NetworkError errorCode = reply->error();
|
||||
if (errorCode != QNetworkReply::NoError) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("Network error: %1.").arg(reply->errorString()));
|
||||
wizard()->enableButtons();
|
||||
const QString message = tr("Network error: %1.").arg(reply->errorString());
|
||||
reply->deleteLater();
|
||||
// A hidden wizard cannot show a modal box: without an explicit stop it would sit
|
||||
// here forever and the hosting client would wait with no timeout.
|
||||
if (wizard()->backgroundMode) {
|
||||
qWarning() << message;
|
||||
wizard()->reject();
|
||||
return;
|
||||
}
|
||||
QMessageBox::critical(this, tr("Error"), message);
|
||||
wizard()->enableButtons();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -218,6 +227,15 @@ void SimpleDownloadFilePage::actDownloadFinished()
|
|||
|
||||
bool SimpleDownloadFilePage::saveToFile()
|
||||
{
|
||||
const auto failSave = [this](const QString &message) {
|
||||
qWarning() << message;
|
||||
if (wizard()->backgroundMode) {
|
||||
wizard()->reject();
|
||||
} else {
|
||||
QMessageBox::critical(this, tr("Error"), message);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
QString defaultPath = getDefaultSavePath();
|
||||
QString windowName = getWindowTitle();
|
||||
QString fileType = getFileType();
|
||||
|
|
@ -236,12 +254,11 @@ bool SimpleDownloadFilePage::saveToFile()
|
|||
QFileInfo fi(fileName);
|
||||
QDir fileDir(fi.path());
|
||||
if (!fileDir.exists() && !fileDir.mkpath(fileDir.absolutePath())) {
|
||||
return false;
|
||||
return failSave(tr("The database directory could not be created: %1").arg(fileDir.absolutePath()));
|
||||
}
|
||||
|
||||
if (!internalSaveToFile(fileName)) {
|
||||
QMessageBox::critical(this, tr("Error"), tr("The file could not be saved to %1").arg(fileName));
|
||||
return false;
|
||||
return failSave(tr("The file could not be saved to %1").arg(fileName));
|
||||
}
|
||||
|
||||
// clean saved downloadData
|
||||
|
|
@ -252,17 +269,10 @@ bool SimpleDownloadFilePage::saveToFile()
|
|||
|
||||
bool SimpleDownloadFilePage::internalSaveToFile(const QString &fileName)
|
||||
{
|
||||
QFile file(fileName);
|
||||
if (!file.open(QIODevice::WriteOnly)) {
|
||||
qDebug() << "File open (w) failed for" << fileName;
|
||||
QString error;
|
||||
if (!OracleDatabase::saveXml(fileName, downloadData, &error)) {
|
||||
qWarning() << error;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (file.write(downloadData) == -1) {
|
||||
qDebug() << "File write (w) failed for" << fileName;
|
||||
return false;
|
||||
}
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue