From 3cef007d12351c2226f1006961795b7a6a4f4ed8 Mon Sep 17 00:00:00 2001 From: Rabindra Dhakal Date: Sun, 3 Nov 2024 22:55:33 +0545 Subject: [PATCH] fix(health): check fusermount3 and use fusermount as fallback --- src/core/health.rs | 35 ++++++++++++++++++++++------------- src/registry/storage.rs | 3 ++- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/src/core/health.rs b/src/core/health.rs index b6cc1bb..9e6872a 100644 --- a/src/core/health.rs +++ b/src/core/health.rs @@ -135,26 +135,35 @@ async fn check_capabilities() -> Option<&'static str> { async fn check_fusermount() { let mut error = String::new(); - match which::which("fusermount") { - Ok(path) => match path.metadata() { + let fusermount_path = match which::which("fusermount3") { + Ok(path) => Some(path), + Err(_) => match which::which("fusermount") { + Ok(path) => Some(path), + Err(_) => { + error = format!( + "{} not found. Please install {}.\n", + "fusermount".color(Color::Blue), + "fuse".color(Color::Blue) + ); + None + } + }, + }; + + if let Some(fusermount_path) = fusermount_path { + match fusermount_path.metadata() { Ok(meta) => { let permissions = meta.permissions().mode(); if permissions != 0o104755 { error = format!( - "Invalid {} file mode bits. Set 4755 for {}", - "fusermount".color(Color::Blue), - path.to_string_lossy().color(Color::Green) + "Invalid file mode bits. Set 4755 for {}.", + fusermount_path.to_string_lossy().color(Color::Green) ); } } - Err(_) => error = "Unable to read fusermount".to_string(), - }, - Err(_) => { - error = format!( - "{} not found. Please install {}", - "fusermount".color(Color::Blue), - "fuse".color(Color::Blue) - ); + Err(_) => { + error = "Unable to read fusermount metadata.".to_owned(); + } } } diff --git a/src/registry/storage.rs b/src/registry/storage.rs index 14ab48f..a7d6e55 100644 --- a/src/registry/storage.rs +++ b/src/registry/storage.rs @@ -399,7 +399,8 @@ impl PackageStorage { resolved_pkg .package .build_script - .replace("tree", "raw/refs/heads") + .replacen("/tree/", "/raw/refs/heads/", 1) + .replacen("/blob/", "/raw/refs/heads/", 1) } else { resolved_pkg.package.build_script };