Name both versions in the firmware overwrite warning

"Firmware 6.20 is installed. It will be erased and replaced with 6.60." is the
thing worth double-checking before wiping a firmware - installing off whatever
disc is to hand makes going backwards easy to do by accident.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Henrik Rydgård
2026-09-10 15:52:53 -06:00
co-authored by Claude Opus 5
parent 86fcfdc60a
commit e4d940604e
4 changed files with 39 additions and 10 deletions
+13 -2
View File
@@ -46,7 +46,8 @@ InstallUpdateScreen::InstallUpdateScreen(const Path &path, std::string_view titl
fileSize_ = fileInfo.size;
}
// There's no practical way to merge two firmwares, so an install replaces whatever is there.
overwrites_ = File::Exists(destination_ / "flash0");
ReadInstalledFirmwareInfo(destination_, &installed_, false);
overwrites_ = installed_.anythingInstalled;
}
std::string_view InstallUpdateScreen::GetTitle() const {
@@ -81,8 +82,18 @@ void InstallUpdateScreen::CreateDialogViews(UI::ViewGroup *parent) {
container->Add(new TextView(GetFriendlyPath(destination_)))->SetAlign(FLAG_WRAP_TEXT);
if (overwrites_) {
// The title is whatever the updater's SFO says, so only trust the tail of it if it came
// out looking like a version number rather than the last word of some other sentence.
std::string newVersion = VersionFromUpdaterTitle(title_);
if (newVersion.find('.') == std::string::npos || newVersion[0] < '0' || newVersion[0] > '9') {
newVersion.clear();
}
const std::string_view unknown = "N/A";
container->Add(new NoticeView(NoticeLevel::WARN, di->T("Confirm Overwrite"),
iz->T("The firmware already installed will be erased first")));
ApplySafeSubstitutions(
iz->T("ReplaceFirmware", "Firmware %1 is installed. It will be erased and replaced with %2."),
installed_.version.empty() ? unknown : std::string_view(installed_.version),
newVersion.empty() ? unknown : std::string_view(newVersion))));
}
container->Add(new Spacer(12.0f));