Skip to content

misterdownloadmanager: The ultimate open-source, clean-room download manager written from scratch in pure Rust for Windows, Mac, and Linux

Update now finds the Linux and macOS files with or without "-experimental" (#270)

Ahmed Nefzaouie9d205e04ea7
diff --git a/CHANGELOG.md b/CHANGELOG.md
index bce663fb..5be43d85 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -587,6 +587,9 @@ Each release's notes on GitHub come from its section here (`## [X.Y.Z]`, see
### Fixed
+- **Update now finds the Linux and macOS files by either name**: a release's AppImage, .deb,
+ .rpm, .tar.gz and .dmg were named `…-experimental`; MDM now looks for the name without it
+ first and still takes the older one, so Update now keeps working whichever a release uses.
- **The Linux .deb and .rpm bring what MDM's window needs** (part of
[#164](https://github.com/anefzaoui/misterdownloadmanager/issues/164)): on a system without
libxkbcommon-x11 (a minimal install, a container), MDM installed from them stopped at start
diff --git a/ROADMAP.md b/ROADMAP.md
index 34016259..facca37f 100644
--- a/ROADMAP.md
+++ b/ROADMAP.md
@@ -13,6 +13,8 @@ Everything below ships together, in one release, as version 0.3.0.
### Done
+- ✅ Update now finds the Linux and macOS release files whether or not their names end in
+ "-experimental"
- ✅ Linux packages checked in clean Ubuntu 24.04, Debian 12 and Fedora 45 systems: install, the
command line, the window, the desktop entry and icon, browser integration and uninstall; the
.deb and .rpm now bring the keyboard library MDM's window needs under X11 and the CA
diff --git a/crates/app/src/update.rs b/crates/app/src/update.rs
index 2af59f02..7438873f 100644
--- a/crates/app/src/update.rs
+++ b/crates/app/src/update.rs
@@ -26,12 +26,14 @@ pub enum Next {
Opened,
}
-/// The release file this copy updates from, when `assets` (name, address) has it and the
-/// signature of the release's checksum list.
+/// The release file this copy updates from, when `assets` (name, address) has it (by either of
+/// its names, [`Install::assets`]) and the signature of the release's checksum list.
pub fn asset_for(install: Install, version: &str, assets: &[(String, String)]) -> Option<String> {
- let name = install.asset(version)?;
let has = |n: &str| assets.iter().any(|(a, _)| a == n);
- (has(&name) && has("SHA256SUMS.txt") && has("SHA256SUMS.txt.sig")).then_some(name)
+ if !(has("SHA256SUMS.txt") && has("SHA256SUMS.txt.sig")) {
+ return None;
+ }
+ install.assets(version).into_iter().find(|n| has(n))
}
/// Where update files are kept until the next start.
@@ -292,4 +294,39 @@ mod tests {
assert_eq!(asset_for(Install::PortableZip, "0.2.2", &full), None);
assert_eq!(asset_for(Install::Source, "0.2.2", &full), None);
}
+
+ /// Linux's and macOS's files lose "-experimental" in a release: a copy finds its file by
+ /// either name, the plain one first.
+ #[test]
+ fn a_release_names_linux_files_either_way() {
+ let release = |names: &[&str]| -> Vec<(String, String)> {
+ names
+ .iter()
+ .chain(&["SHA256SUMS.txt", "SHA256SUMS.txt.sig"])
+ .map(|n| (n.to_string(), format!("https://x/{n}")))
+ .collect()
+ };
+ let old = "MisterDownloadManager-0.3.0-linux-x86_64-experimental.AppImage";
+ let new = "MisterDownloadManager-0.3.0-linux-x86_64.AppImage";
+ let deb = "MisterDownloadManager-0.3.0-linux-x86_64.deb";
+ for (assets, want) in [
+ (release(&[old]), Some(old)),
+ (release(&[new, deb]), Some(new)),
+ (release(&[old, new]), Some(new)),
+ (release(&[deb]), None),
+ ] {
+ assert_eq!(
+ asset_for(Install::AppImage, "0.3.0", &assets).as_deref(),
+ want,
+ "{assets:?}"
+ );
+ }
+ assert_eq!(
+ asset_for(Install::Deb, "0.3.0", &release(&[new, deb])).as_deref(),
+ Some(deb)
+ );
+ // Unsigned: neither.
+ let unsigned = vec![(new.to_string(), format!("https://x/{new}"))];
+ assert_eq!(asset_for(Install::AppImage, "0.3.0", &unsigned), None);
+ }
}
diff --git a/crates/tools/src/update.rs b/crates/tools/src/update.rs
index 0fc45dd5..af3b548e 100644
--- a/crates/tools/src/update.rs
+++ b/crates/tools/src/update.rs
@@ -96,24 +96,30 @@ impl Install {
Install::Source,
];
- /// The release file of `version` that replaces this kind of copy (the names
- /// tools/installer/*.sh and build.ps1 give them).
- pub fn asset(self, version: &str) -> Option<String> {
- let tail = match self {
- Install::Installer => "setup.exe",
- Install::PortableZip => "portable.zip",
- Install::PlainZip => "x64.zip",
+ /// The release files of `version` that replace this kind of copy (the names
+ /// tools/installer/*.sh and build.ps1 give them), the one to take first first. The Linux and
+ /// macOS files were named `…-experimental` up to 0.2.x; a release may name them either way,
+ /// so both are looked for, the plain name first. None for a build from source.
+ pub fn assets(self, version: &str) -> Vec<String> {
+ let (tail, ext) = match self {
+ Install::Installer => ("setup", ".exe"),
+ Install::PortableZip => ("portable", ".zip"),
+ Install::PlainZip => ("x64", ".zip"),
// One app per processor (tools/installer/build-macos.sh, #25). 0.2.4 and older look
// for the universal one, find it missing and offer the release's page instead.
- Install::Dmg if cfg!(target_arch = "aarch64") => "macos-arm64-experimental.dmg",
- Install::Dmg => "macos-x86_64-experimental.dmg",
- Install::AppImage => "linux-x86_64-experimental.AppImage",
- Install::Deb => "linux-x86_64-experimental.deb",
- Install::Rpm => "linux-x86_64-experimental.rpm",
- Install::TarGz => "linux-x86_64-experimental.tar.gz",
- Install::Source => return None,
+ Install::Dmg if cfg!(target_arch = "aarch64") => ("macos-arm64", ".dmg"),
+ Install::Dmg => ("macos-x86_64", ".dmg"),
+ Install::AppImage => ("linux-x86_64", ".AppImage"),
+ Install::Deb => ("linux-x86_64", ".deb"),
+ Install::Rpm => ("linux-x86_64", ".rpm"),
+ Install::TarGz => ("linux-x86_64", ".tar.gz"),
+ Install::Source => return Vec::new(),
};
- Some(format!("MisterDownloadManager-{version}-{tail}"))
+ let name = |tail: &str| format!("MisterDownloadManager-{version}-{tail}{ext}");
+ match self {
+ Install::Installer | Install::PortableZip | Install::PlainZip => vec![name(tail)],
+ _ => vec![name(tail), name(&format!("{tail}-experimental"))],
+ }
}
}
@@ -373,13 +379,32 @@ Connection: close
#[test]
fn every_kind_has_its_release_file() {
assert_eq!(
- Install::Installer.asset("0.2.2").as_deref(),
- Some("MisterDownloadManager-0.2.2-setup.exe")
+ Install::Installer.assets("0.2.2"),
+ ["MisterDownloadManager-0.2.2-setup.exe"]
);
assert_eq!(
- Install::TarGz.asset("1.0.0").as_deref(),
- Some("MisterDownloadManager-1.0.0-linux-x86_64-experimental.tar.gz")
+ Install::PortableZip.assets("0.2.2"),
+ ["MisterDownloadManager-0.2.2-portable.zip"]
);
+ assert_eq!(
+ Install::PlainZip.assets("0.2.2"),
+ ["MisterDownloadManager-0.2.2-x64.zip"]
+ );
+ // Linux and macOS: the plain name first, then the one up to 0.2.x.
+ for (install, ext) in [
+ (Install::TarGz, ".tar.gz"),
+ (Install::AppImage, ".AppImage"),
+ (Install::Deb, ".deb"),
+ (Install::Rpm, ".rpm"),
+ ] {
+ assert_eq!(
+ install.assets("1.0.0"),
+ [
+ format!("MisterDownloadManager-1.0.0-linux-x86_64{ext}"),
+ format!("MisterDownloadManager-1.0.0-linux-x86_64-experimental{ext}"),
+ ]
+ );
+ }
// The .dmg for the Mac's own processor.
let arch = if cfg!(target_arch = "aarch64") {
"arm64"
@@ -387,12 +412,13 @@ Connection: close
"x86_64"
};
assert_eq!(
- Install::Dmg.asset("1.0.0"),
- Some(format!(
- "MisterDownloadManager-1.0.0-macos-{arch}-experimental.dmg"
- ))
+ Install::Dmg.assets("1.0.0"),
+ [
+ format!("MisterDownloadManager-1.0.0-macos-{arch}.dmg"),
+ format!("MisterDownloadManager-1.0.0-macos-{arch}-experimental.dmg"),
+ ]
);
- assert_eq!(Install::Source.asset("1.0.0"), None);
+ assert!(Install::Source.assets("1.0.0").is_empty());
let labels: std::collections::HashSet<_> = Install::ALL.iter().map(|i| i.label()).collect();
assert_eq!(labels.len(), Install::ALL.len());
}