Handle the case where the path is already absolute

This commit is contained in:
Thorsten Sommer 2025-03-03 14:46:19 +01:00
parent ef5ff66939
commit dc00983539
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108

View File

@ -78,6 +78,13 @@ pub fn init_logging() {
fn convert_log_path_to_string(log_path: &FileSpec) -> String { fn convert_log_path_to_string(log_path: &FileSpec) -> String {
let log_path = log_path.as_pathbuf(None); let log_path = log_path.as_pathbuf(None);
// Case: The path is already absolute:
if log_path.is_absolute() {
return log_path.to_str().unwrap().to_string();
}
// Case: The path is relative. Let's try to convert it to an absolute path:
match log_path.canonicalize() { match log_path.canonicalize() {
// Case: The path exists: // Case: The path exists:
Ok(log_path) => log_path.to_str().unwrap().to_string(), Ok(log_path) => log_path.to_str().unwrap().to_string(),