feat(app): the window tells when a newer version exists and where to get it (P15 C1)
Update is an ordinary app update: the newer package installed over the old one. The program's part is to say one exists. Once a day, on a thread of its own, it reads one small file a release publishes (latest.json: only a version number is taken from it; where to get the update is a fixed address in the program) and notes the answer in the data root's updates folder. A higher x.y.z shows a standing notice with a button that opens the download page and the words that books, keys and connections stay. Check for updates does the same look at once on every platform; where a program may replace itself with a signed release it also stages one as before. A macOS app is never replaced one file at a time (that breaks its signature): it is treated as managed, and says to drag the new app over the old. Window prose names the product Wanderbooks. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
2bc442f795
commit
90f663ed54
8 files changed
+510
-49
No files matched your search
@@ -1525,39 +1525,45 @@ pub fn update_waiting(_common: &Common) -> Option<UpdateWaiting> {
|
||||
None
|
||||
}
|
||||
|
||||
/// "Check for updates": look at the feed now, whatever the daily look
|
||||
/// last did, and stage a newer release if there is one (it never swaps
|
||||
/// the program: accepting is [`apply_update`]). What came of it.
|
||||
#[cfg(unix)]
|
||||
/// "Check for updates": say whether a newer version exists and where to
|
||||
/// get it (the note of [`crate::newer`], looked at now whatever the last
|
||||
/// look was). Where a program may replace itself (an AppImage, a program
|
||||
/// put somewhere by hand, with a release key) a newer release is also
|
||||
/// downloaded and checked, for [`apply_update`] (it never swaps the
|
||||
/// program: accepting is). What came of it.
|
||||
pub fn check_for_updates(common: &Common) -> Result<String, String> {
|
||||
let found =
|
||||
ledger_store::root::Root::find(common.root.as_deref()).map_err(|e| e.to_string())?;
|
||||
let mine = crate::update::program_version();
|
||||
if let crate::update::Install::PackageManaged(manager) = crate::update::this_install()? {
|
||||
return Err(format!(
|
||||
"this install is updated by {manager}, not here: use the package manager"
|
||||
));
|
||||
}
|
||||
match crate::update::stage_if_due(&found, mine, Duration::ZERO) {
|
||||
Ok(Some(version)) => Ok(format!(
|
||||
"Version {version} is downloaded and checked. Accept it to start using it."
|
||||
)),
|
||||
Ok(None) => Ok(match update_waiting(common) {
|
||||
Some(u) => format!(
|
||||
"Version {} is downloaded and checked. Accept it to start using it.",
|
||||
u.version
|
||||
),
|
||||
None => format!("You have the newest version ({mine})."),
|
||||
}),
|
||||
Err(why) => Err(why.to_string()),
|
||||
let mine = crate::program_version();
|
||||
#[cfg(unix)]
|
||||
if let Ok(crate::update::Install::SelfUpdating(_)) = crate::update::this_install() {
|
||||
match crate::update::stage_if_due(&found, mine, Duration::ZERO) {
|
||||
Ok(Some(version)) => {
|
||||
return Ok(format!(
|
||||
"Version {version} is downloaded and checked. Accept it to start using it."
|
||||
));
|
||||
}
|
||||
Ok(None) => {
|
||||
if let Some(u) = update_waiting(common) {
|
||||
return Ok(format!(
|
||||
"Version {} is downloaded and checked. Accept it to start using it.",
|
||||
u.version
|
||||
));
|
||||
}
|
||||
}
|
||||
// No release key or local feed: the look below still tells.
|
||||
Err(_) => {}
|
||||
}
|
||||
}
|
||||
crate::newer::check_now(found.path(), mine)
|
||||
}
|
||||
|
||||
/// Checking for updates isn't built for this platform: say so, and
|
||||
/// change nothing.
|
||||
#[cfg(not(unix))]
|
||||
pub fn check_for_updates(_common: &Common) -> Result<String, String> {
|
||||
Err(NO_SELF_UPDATE.into())
|
||||
/// The newer version the window may tell the person of, with where to get
|
||||
/// it: what the last (daily) look found, a look begun when one is due.
|
||||
pub fn newer_version(common: &Common) -> Option<(String, &'static str)> {
|
||||
let found = ledger_store::root::Root::find(common.root.as_deref()).ok()?;
|
||||
let version = crate::newer::found_and_refresh(found.path(), crate::program_version())?;
|
||||
Some((version, crate::newer::DOWNLOAD_PAGE))
|
||||
}
|
||||
|
||||
/// Accept the staged update: the books' host installs it and restarts
|
||||
|
||||
Reference in new issue
Block a user