Signed-off-by: renoseven <dev@renoseven.net> (cherry picked from commit ee389461c106cec66c0e7e2d493c4e1fd1fb6a6d)
29 lines
885 B
Diff
29 lines
885 B
Diff
From 25d19d0d5f5acdd7833bd73afcb16a693e54fbd4 Mon Sep 17 00:00:00 2001
|
|
From: renoseven <dev@renoseven.net>
|
|
Date: Tue, 13 Aug 2024 17:31:50 +0800
|
|
Subject: [PATCH] common: fix 'normalize empty path return current path' issue
|
|
|
|
Signed-off-by: renoseven <dev@renoseven.net>
|
|
---
|
|
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<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
|
|
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
|
|
|