Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ The release notes for each tag are taken from the section for that version.
## Unreleased

### Fixed
- **Launcher update:** pressing Update no longer makes the update card disappear with nothing happening. The card now stays through the download and shows **Restart now** when the new version is ready; before, the window lost the version's name once the download started, so that button never appeared. A failed download says why and offers Try again and the download page.
- **Fix and verify after a rebuild:** when the build finishes but its program is missing, the launcher says where it expected it and suggests checking antivirus, instead of telling you to press Install.
- **Linux builds of Windows-only games:** a build that fails because the project uses Windows-only libraries now says so in the log, instead of only showing the compiler's error.

Expand Down
9 changes: 6 additions & 3 deletions src-tauri/src/launcher/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -546,14 +546,17 @@ impl App {
}

fn updater_view(&self) -> UpdaterView {
// The release being installed, while it downloads, once it is ready and after a failure:
// the window shows the update card only for a release it can name.
let found = || self.updater.release.as_ref().map(|r| r.tag_name.clone());
let (state, tag, error) = match &self.updater.state {
UpdaterState::Idle => ("idle", None, None),
UpdaterState::Checking => ("checking", None, None),
UpdaterState::Current => ("current", None, None),
UpdaterState::Available(release) => ("available", Some(release.tag_name.clone()), None),
UpdaterState::Downloading => ("downloading", None, None),
UpdaterState::Downloaded(_) => ("downloaded", None, None),
UpdaterState::Failed(error) => ("failed", None, Some(localize(error))),
UpdaterState::Downloading => ("downloading", found(), None),
UpdaterState::Downloaded(_) => ("downloaded", found(), None),
UpdaterState::Failed(error) => ("failed", found(), Some(localize(error))),
};
UpdaterView {
state,
Expand Down
54 changes: 50 additions & 4 deletions src-tauri/src/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const MAX_BYTES: u64 = 64 * 1024 * 1024;
#[cfg(not(windows))]
const MAX_BYTES: u64 = 400 * 1024 * 1024;

#[derive(Deserialize)]
#[derive(Clone, Deserialize)]
pub struct Release {
pub tag_name: String,
assets: Vec<Asset>,
}

#[derive(Deserialize)]
#[derive(Clone, Deserialize)]
struct Asset {
name: String,
size: u64,
Expand Down Expand Up @@ -58,6 +58,9 @@ pub struct Updater {
pub state: State,
pub restart_requested: bool,
pub restart_error: Option<String>,
/// The newer release the last check found, kept while it downloads, once it is ready and
/// after a failed download: the window names it in each of those, and Update tries it again.
pub release: Option<Release>,
result: Option<Receiver<Result<State, String>>>,
}

Expand All @@ -73,6 +76,16 @@ impl Updater {
}
};
self.result = None;
self.keep_release();
}

/// Keeps the release a check found; forgets it when the check says this version is current.
fn keep_release(&mut self) {
match &self.state {
State::Available(release) => self.release = Some(release.clone()),
State::Current => self.release = None,
_ => {}
}
}

pub fn check(&mut self, ctx: &Ctx) {
Expand All @@ -81,9 +94,13 @@ impl Updater {
self.start(ctx, State::Checking, check_release);
}

/// Downloads the release found: from "available", or again after a failed download.
/// Anything else (a download already running, one ready) is left as it is.
pub fn download(&mut self, ctx: &Ctx) {
let State::Available(release) = std::mem::take(&mut self.state) else {
return;
let release = match (&self.state, &self.release) {
(State::Available(release), _) => release.clone(),
(State::Failed(_), Some(release)) => release.clone(),
_ => return,
};
self.restart_requested = true;
self.restart_error = None;
Expand Down Expand Up @@ -472,6 +489,35 @@ fn release_links_follow_the_brand() {
assert_eq!(RELEASES, format!("{}/releases", crate::brand::SOURCE_URL));
}

#[cfg(test)]
fn release_fixture(tag: &str) -> Release {
Release {
tag_name: tag.into(),
assets: Vec::new(),
}
}

#[cfg(test)]
#[test]
fn the_release_found_is_kept_through_its_download_and_a_failure() {
let mut updater = Updater {
state: State::Available(release_fixture("v9.0.0")),
..Updater::default()
};
updater.keep_release();
// A download that fails keeps the release, so the window still names it.
updater.state = State::Failed("offline".into());
updater.keep_release();
assert_eq!(
updater.release.as_ref().map(|r| r.tag_name.as_str()),
Some("v9.0.0")
);
// A later check that finds this version current forgets it.
updater.state = State::Current;
updater.keep_release();
assert!(updater.release.is_none());
}

#[cfg(test)]
#[test]
fn compares_stable_versions_numerically() {
Expand Down
14 changes: 14 additions & 0 deletions src/features/shared/launcher-update.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,26 @@ export function LauncherUpdate() {
return (
<Card>
<p className="text-caption text-fg-2">{t("shell.update.ready", { tag })}</p>
{u.restart_error && <p className="mt-1 text-caption text-fg-3">{u.restart_error}</p>}
<div className="mt-2">
<Button size="sm" variant="primary" onClick={() => void run({ type: "restart_to_update" })}>{t("shell.update.restart")}</Button>
</div>
</Card>
)
}
// A download that failed says why, and can be tried again or fetched from the Releases page.
if (u.state === "failed") {
return (
<Card>
<p className="text-caption text-fg-2">{t("shell.update.failed", { tag })}</p>
{u.error && <p className="mt-1 text-caption text-fg-3">{u.error}</p>}
<div className="mt-2 flex flex-wrap gap-1.5">
<Button size="sm" variant="primary" onClick={() => void run({ type: "download_update" })}>{t("common.retry")}</Button>
<Button size="sm" variant="ghost" onClick={() => void openUrl(u.releases)}>{t("shell.update.page")}</Button>
</div>
</Card>
)
}
return null
}

Expand Down
2 changes: 2 additions & 0 deletions src/i18n/messages/en/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,7 @@ export default {
downloading: "Downloading {tag}",
ready: "{tag} is ready",
restart: "Restart now",
failed: "Could not update to {tag}",
page: "Download page",
},
} as const
2 changes: 2 additions & 0 deletions src/i18n/messages/es/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@ export default {
downloading: "Descargando {tag}",
ready: "{tag} está listo",
restart: "Reiniciar ahora",
failed: "No se pudo actualizar a {tag}",
page: "Página de descarga",
},
} satisfies Translation<typeof en>
2 changes: 2 additions & 0 deletions src/i18n/messages/fr/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@ export default {
downloading: "Téléchargement de {tag}",
ready: "{tag} est prêt",
restart: "Redémarrer maintenant",
failed: "Impossible de passer à {tag}",
page: "Page de téléchargement",
},
} satisfies Translation<typeof en>
2 changes: 2 additions & 0 deletions src/i18n/messages/ru/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,7 @@ export default {
downloading: "Загрузка {tag}",
ready: "{tag} готов к установке",
restart: "Перезапустить сейчас",
failed: "Не удалось обновиться до {tag}",
page: "Страница загрузки",
},
} as const
2 changes: 2 additions & 0 deletions src/i18n/messages/zh-CN/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@ export default {
downloading: "正在下载 {tag}",
ready: "{tag} 已就绪",
restart: "立即重启",
failed: "无法更新到 {tag}",
page: "下载页面",
},
} satisfies Translation<typeof en>
2 changes: 2 additions & 0 deletions src/i18n/messages/zh-TW/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,7 @@ export default {
downloading: "正在下載 {tag}",
ready: "{tag} 已準備就緒",
restart: "立即重新啟動",
failed: "無法更新到 {tag}",
page: "下載頁面",
},
} satisfies Translation<typeof en>
Loading