From 637d6146180ca14f9b5e1be1110d7f025f88a4d6 Mon Sep 17 00:00:00 2001 From: weisd Date: Mon, 9 Dec 2024 17:43:18 +0800 Subject: [PATCH] fix find_local_disk --- ecstore/src/store.rs | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/ecstore/src/store.rs b/ecstore/src/store.rs index 86dda946e..102cf8f48 100644 --- a/ecstore/src/store.rs +++ b/ecstore/src/store.rs @@ -930,20 +930,13 @@ async fn update_scan( } pub async fn find_local_disk(disk_path: &String) -> Option { - let disk_path = match fs::canonicalize(disk_path).await { - Ok(disk_path) => disk_path, - Err(_) => return None, - }; - let disk_map = GLOBAL_LOCAL_DISK_MAP.read().await; - let path = disk_path.to_string_lossy().to_string(); - if disk_map.contains_key(&path) { - let a = disk_map[&path].as_ref().cloned(); - - return a; + if let Some(disk) = disk_map.get(disk_path) { + disk.as_ref().cloned() + } else { + None } - None } pub async fn get_disk_via_endpoint(endpoint: &Endpoint) -> Option {