fix bug with uploading unnamed decks ignoring the prompt (#5313)

This commit is contained in:
RickyRister
2024-12-23 17:39:57 -08:00
committed by GitHub
parent 705b1e0c2b
commit 0234a70bfd

View File

@@ -176,14 +176,8 @@ void TabDeckStorage::actUpload()
QFile deckFile(filePath);
QFileInfo deckFileInfo(deckFile);
QString deckString;
DeckLoader deck;
bool error = !deck.loadFromFile(filePath, DeckLoader::CockatriceFormat);
if (!error) {
deckString = deck.writeToString_Native();
error = deckString.length() > MAX_FILE_LENGTH;
}
if (error) {
if (!deck.loadFromFile(filePath, DeckLoader::CockatriceFormat)) {
QMessageBox::critical(this, tr("Error"), tr("Invalid deck file"));
return;
}
@@ -202,6 +196,12 @@ void TabDeckStorage::actUpload()
deck.setName(deck.getName().left(MAX_NAME_LENGTH));
}
QString deckString = deck.writeToString_Native();
if (deckString.length() > MAX_FILE_LENGTH) {
QMessageBox::critical(this, tr("Error"), tr("Invalid deck file"));
return;
}
Command_DeckUpload cmd;
cmd.set_path(targetPath.toStdString());
cmd.set_deck_list(deckString.toStdString());