From f99b55e416c5a86ab472bda32b901b5cdd236023 Mon Sep 17 00:00:00 2001 From: Pierre Jacquier Date: Thu, 15 Feb 2024 05:13:20 -0500 Subject: [PATCH] cargo fmt --- src-tauri/src/main.rs | 42 ++++++++++++++++++++------------------- src-tauri/tauri.conf.json | 2 +- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 033241f24..6522e3b78 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -44,7 +44,9 @@ pub struct DiskEntry { /// From https://github.com/tauri-apps/tauri/blob/1.x/core/tauri/src/api/dir.rs#L51 /// Removed from tauri v2 fn is_dir>(path: P) -> Result { - std::fs::metadata(path).map(|md| md.is_dir()).map_err(Into::into) + std::fs::metadata(path) + .map(|md| md.is_dir()) + .map_err(Into::into) } /// From https://github.com/tauri-apps/tauri/blob/1.x/core/tauri/src/api/dir.rs#L51 @@ -54,27 +56,27 @@ fn read_dir_recursive(path: &str) -> Result, InvokeError> { let mut files_and_dirs: Vec = vec![]; // let path = path.as_ref(); for entry in fs::read_dir(path).map_err(|e| InvokeError::from_anyhow(e.into()))? { - let path = entry.map_err(|e| InvokeError::from_anyhow(e.into()))?.path(); - - if let Ok(flag) = is_dir(&path) { - files_and_dirs.push(DiskEntry { - path: path.clone(), - children: if flag { - Some( - read_dir_recursive(path.to_str().expect("No path"))? - ) - } else { - None - }, - name: path - .file_name() - .map(|name| name.to_string_lossy()) - .map(|name| name.to_string()), - }); - } + let path = entry + .map_err(|e| InvokeError::from_anyhow(e.into()))? + .path(); + + if let Ok(flag) = is_dir(&path) { + files_and_dirs.push(DiskEntry { + path: path.clone(), + children: if flag { + Some(read_dir_recursive(path.to_str().expect("No path"))?) + } else { + None + }, + name: path + .file_name() + .map(|name| name.to_string_lossy()) + .map(|name| name.to_string()), + }); + } } Ok(files_and_dirs) - } +} /// This command returns a string that is the contents of a file at the path. #[tauri::command] diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f84cdb1f5..0a10b98c3 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -57,4 +57,4 @@ }, "productName": "zoo-modeling-app", "version": "0.14.0" -} \ No newline at end of file +}