From 4040168e8a3c0e26c5a12fea0c2f85a28508a774 Mon Sep 17 00:00:00 2001 From: kwaroran Date: Tue, 1 Aug 2023 12:12:09 +0900 Subject: [PATCH] [feat] check file is a file --- src-tauri/src/main.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 31016a42..f37db11a 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -84,6 +84,13 @@ fn check_auth(fpath: String, auth: String) -> bool{ println!("File {} does not exist", path.display()); return false; } + + // check file is a file + if !path.is_file() { + println!("File {} is not a file", path.display()); + return false; + } + // check file size let size = std::fs::metadata(&fpath).unwrap().len(); @@ -92,6 +99,7 @@ fn check_auth(fpath: String, auth: String) -> bool{ println!("File {} is too large", path.display()); return false; } + // read file