From 8ac6f6b909fc6aed098783572682d52d1c9d3762 Mon Sep 17 00:00:00 2001 From: Dongdong Zhou Date: Mon, 18 Oct 2021 14:26:57 +0100 Subject: [PATCH] get file with permission --- proxy/src/dispatch.rs | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/proxy/src/dispatch.rs b/proxy/src/dispatch.rs index 6c724473..4c27b28f 100644 --- a/proxy/src/dispatch.rs +++ b/proxy/src/dispatch.rs @@ -575,24 +575,31 @@ fn handle_request(&self, id: RequestId, rpc: Request) { let mut dirs = Vec::new(); dirs.push(workspace.clone()); while let Some(dir) = dirs.pop() { - for entry in fs::read_dir(dir).unwrap() { - let entry = entry.unwrap(); - let path = entry.path(); - if entry.file_name().to_str().unwrap().starts_with(".") { - continue; - } - if path.is_dir() { - if !path - .as_path() + if let Ok(readdir) = fs::read_dir(dir) { + for entry in readdir { + let entry = entry.unwrap(); + let path = entry.path(); + if entry + .file_name() .to_str() .unwrap() - .to_string() - .ends_with("target") + .starts_with(".") { - dirs.push(path); + continue; + } + if path.is_dir() { + if !path + .as_path() + .to_str() + .unwrap() + .to_string() + .ends_with("target") + { + dirs.push(path); + } + } else { + items.push(path.to_str().unwrap().to_string()); } - } else { - items.push(path.to_str().unwrap().to_string()); } } }