From 59cdabc89ceda742b77d96315d2ac2d71e8aae16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Ant=C3=B4nio=20Cardoso?= Date: Fri, 28 Apr 2023 14:21:13 -0300 Subject: [PATCH] src: cli: Remove unwraps while resolving the symlink case for current execution path --- src/cli/manager.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/cli/manager.rs b/src/cli/manager.rs index c0336f85..c8b77f8a 100644 --- a/src/cli/manager.rs +++ b/src/cli/manager.rs @@ -1,3 +1,4 @@ +use anyhow::Context; use clap; use std::sync::Arc; use tracing::error; @@ -14,11 +15,14 @@ lazy_static! { static ref CURRENT_EXECUTION_WWW_PATH: String = format!( "{}/www", std::env::current_exe() - .unwrap() - .parent() - .unwrap() - .to_str() - .unwrap() + .and_then(std::fs::canonicalize) + .map_err(anyhow::Error::msg) + .and_then(|path| path + .to_owned() + .to_str() + .context("Failed to convert path to str") + .map(String::from)) + .expect("Failed to get current executable path") ); }