Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Havunen committed Oct 1, 2024
1 parent 4ec90be commit b017f67
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ pub(crate) async fn canonicalize<P: AsRef<Path> + Unpin>(path: P) -> std::io::Re
/// Absolute path
///
pub(crate) fn absolute(path: PathBuf) -> std::io::Result<PathBuf> {
let path = if path.is_absolute() { path } else { std::env::current_dir()?.join(path) };
let path = if path.is_absolute() {
path
} else {
std::env::current_dir()?.join(path)
};
Ok(dunce::simplified(&path).to_path_buf())
}

Expand All @@ -43,10 +47,13 @@ pub(crate) async fn canonicalize_except_snap(path: PathBuf) -> std::io::Result<P
let executable_cleaned: PathBuf = canonicalize(&path).await?;

// Handle case where executable is provided by snap, ignore canonicalize result and only make path absolute
Ok(if executable_cleaned.to_str().unwrap().ends_with("/snap") { absolute(path).unwrap() } else { executable_cleaned })
Ok(if executable_cleaned.to_str().unwrap().ends_with("/snap") {
absolute(path).unwrap()
} else {
executable_cleaned
})
}


pub(crate) mod base64 {
use base64::engine::general_purpose::STANDARD;
use base64::{DecodeError, Engine};
Expand Down

0 comments on commit b017f67

Please sign in to comment.