From 448508775930f1438e4f4c44d9f4b047ced9272f Mon Sep 17 00:00:00 2001 From: "H. Emre ARI" Date: Wed, 27 Mar 2019 16:21:03 +0300 Subject: [PATCH] fix crash when given file doesn't exist --- src/core.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/core.rs b/src/core.rs index b8ae9f5..02096a1 100644 --- a/src/core.rs +++ b/src/core.rs @@ -67,8 +67,16 @@ impl Core { }; for path in paths { + let absolute_path = match fs::canonicalize(&path) { + Ok(path) => path, + Err(err) => { + println!("couldn't access '{}': {}", path.display(), err); + continue; + } + }; + match Meta::from_path_recursive( - &fs::canonicalize(&path.to_path_buf()).unwrap(), + &fs::canonicalize(&absolute_path.to_path_buf()).unwrap(), depth, self.flags.display_all, ) {