From 0f09fc76d4390811be71bc0e9a0e44a50ecb6440 Mon Sep 17 00:00:00 2001 From: Jan Date: Thu, 2 Feb 2023 13:06:34 +0100 Subject: refactor: Deal with `fs::read_dir` failure instead of checking if exists (#155) * refactor: Deal with fs::read_dir failure instead of checking if exists --- src-tauri/src/repair_and_verify/mod.rs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs index fb108f37..5d58dfaf 100644 --- a/src-tauri/src/repair_and_verify/mod.rs +++ b/src-tauri/src/repair_and_verify/mod.rs @@ -71,13 +71,11 @@ pub fn clean_up_download_folder( pub fn get_log_list(game_install: GameInstall) -> Result, String> { let ns_log_folder = format!("{}/R2Northstar/logs", game_install.game_path); - // Check if logs folder exists - if !std::path::Path::new(&ns_log_folder).exists() { - return Err("No logs folder found".to_string()); - } - // List files in logs folder - let paths = std::fs::read_dir(ns_log_folder).unwrap(); + let paths = match std::fs::read_dir(ns_log_folder) { + Ok(paths) => paths, + Err(_err) => return Err("No logs folder found".to_string()), + }; // Stores paths of log files let mut log_files: Vec = Vec::new(); -- cgit v1.2.3