From e07e30d88d38227f9899b1a7a2e6de85e2f36c4e Mon Sep 17 00:00:00 2001 From: renoseven Date: Tue, 13 Aug 2024 17:31:50 +0800 Subject: [PATCH] common: fix 'normalize empty path return current path' issue Signed-off-by: renoseven --- syscare-common/src/fs/fs_impl.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/syscare-common/src/fs/fs_impl.rs b/syscare-common/src/fs/fs_impl.rs index e794c98..29c5d6e 100644 --- a/syscare-common/src/fs/fs_impl.rs +++ b/syscare-common/src/fs/fs_impl.rs @@ -290,6 +290,10 @@ pub fn normalize>(path: P) -> io::Result { let mut new_path = PathBuf::new(); let orig_path = path.as_ref(); + if orig_path.as_os_str().is_empty() { + return Ok(new_path); + } + if orig_path.is_relative() { new_path.push(env::current_dir()?); } -- 2.34.1