1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Make cli fw installation more foolproof

This commit is contained in:
Megamouse 2021-03-20 11:17:26 +01:00
parent b5698ee101
commit 70c98fff19
2 changed files with 29 additions and 23 deletions

View File

@ -774,24 +774,28 @@ int main(int argc, char** argv)
// Force install firmware first if specified through command-line
if (parser.isSet(arg_installfw))
{
firmware_path = parser.value(installfw_option).toStdString();
if (!fs::is_file(firmware_path))
if (auto gui_app = qobject_cast<gui_application*>(app.data()))
{
report_fatal_error(fmt::format("No firmware file found: %s", firmware_path));
return 1;
if (s_no_gui)
{
report_fatal_error("Cannot install firmware in no-gui mode!");
return 1;
}
if (gui_app->m_main_window)
{
gui_app->m_main_window->HandlePupInstallation(parser.value(installfw_option));
}
else
{
report_fatal_error("Cannot install firmware. No main window found!");
return 1;
}
}
else
{
if (auto gui_app = qobject_cast<gui_application*>(app.data()))
{
main_window* main_window = gui_app->m_main_window;
if (!main_window)
{
report_fatal_error("Cannot install firmware, exiting !");
return 1;
}
main_window->HandlePupInstallation(QString::fromStdString(firmware_path));
}
report_fatal_error("Cannot install firmware in headless mode!");
return 1;
}
}
@ -800,7 +804,7 @@ int main(int argc, char** argv)
sys_log.notice("Option passed via command line: %s %s", opt.toStdString(), parser.value(opt).toStdString());
}
if (const QStringList args = parser.positionalArguments(); !args.isEmpty() && !is_updating)
if (const QStringList args = parser.positionalArguments(); !args.isEmpty() && !is_updating && !parser.isSet(arg_installfw))
{
sys_log.notice("Booting application from command line: %s", args.at(0).toStdString());

View File

@ -918,8 +918,18 @@ void main_window::ExtractTar()
void main_window::HandlePupInstallation(QString file_path, QString dir_path)
{
const auto critical = [this](QString str)
{
Emu.CallAfter([this, str = std::move(str)]()
{
QMessageBox::critical(this, tr("Firmware Installation Failed"), str);
}, false);
};
if (file_path.isEmpty())
{
gui_log.error("Error while installing firmware: provided path is empty.");
critical(tr("Firmware installation failed: The provided path is empty."));
return;
}
@ -935,14 +945,6 @@ void main_window::HandlePupInstallation(QString file_path, QString dir_path)
const std::string path = sstr(file_path);
auto critical = [this](QString str)
{
Emu.CallAfter([this, str = std::move(str)]()
{
QMessageBox::critical(this, tr("Firmware Installation Failed"), str);
}, false);
};
fs::file pup_f(path);
if (!pup_f)
{