Merge pull request #1860 from ludovic111/fix/launcher-pack-test-windows

🤖 Agent: merged after verify and a launcher dry run on all three platforms (Windows tests pass); the launcher release follows.
This commit is contained in:
Ludovic Marie
2026-10-25 17:25:11 +01:00
committed by GitHub
2 changed files with 21 additions and 2 deletions
+9
View File
@@ -343,6 +343,7 @@ fn fetch(
) -> Result<PathBuf, String> {
match file.url.strip_prefix("file://").filter(|_| local) {
Some(path) => {
let path = local_path(path);
let reader = fs::File::open(path).map_err(|e| format!("{path}: {e}"))?;
download::save_from_anywhere(file, reader, folder, progress)
}
@@ -350,6 +351,14 @@ fn fetch(
}
}
/// The path of a `file:///` URL: on Windows `/C:/x` is `C:/x`.
fn local_path(path: &str) -> &str {
match path.strip_prefix('/') {
Some(rest) if cfg!(windows) && rest.get(1..2) == Some(":") => rest,
_ => path,
}
}
/// What the registry adds to an installed entry.
fn trust_label(trust: Trust) -> &'static str {
match trust {
+12 -2
View File
@@ -208,6 +208,16 @@ mod tests {
zip.write_all(b"renderDistance:8\n").unwrap();
zip.finish().unwrap();
let size = |p: &Path| fs::metadata(p).unwrap().len();
// A `file:///` URL: forward slashes (a Windows path's backslashes would be escapes in
// the JSON) and a leading slash before a Windows drive.
let url = |p: &Path| {
let path = p.display().to_string().replace('\\', "/");
if path.starts_with('/') {
path
} else {
format!("/{path}")
}
};
let text = format!(
r#"{{"schema": 1, "projects": [
{{"id": "coords_hud", "kind": "mod", "name": "Coordinates HUD", "summary": "", "license": "MIT",
@@ -219,9 +229,9 @@ mod tests {
"requires": [{{"id": "coords_hud", "version": "0.1.0", "sha256": "{hmod_sha}"}}],
"file": {{"name": "cozy-1.0.0.hpack", "url": "file://{}", "size": {}, "sha256": "{}"}}}}]}}
]{extra}}}"#,
hmod.display(),
url(&hmod),
size(&hmod),
hpack.display(),
url(&hpack),
size(&hpack),
idx::sha256_file(&hpack).unwrap()
);