diff --git a/src-tauri/src/core/fs.rs b/src-tauri/src/core/fs.rs index 38732dfee..7b3afa8c6 100644 --- a/src-tauri/src/core/fs.rs +++ b/src-tauri/src/core/fs.rs @@ -12,8 +12,17 @@ pub fn rm(app_handle: tauri::AppHandle, args: Vec) -> Res } let path = resolve_path(app_handle, &args[0]); - fs::remove_dir_all(&path).map_err(|e| e.to_string()) + if path.is_file() { + fs::remove_file(&path).map_err(|e| e.to_string())?; + } else if path.is_dir() { + fs::remove_dir_all(&path).map_err(|e| e.to_string())?; + } else { + return Err("rm error: Path does not exist".to_string()); + } + + Ok(()) } + #[tauri::command] pub fn mkdir(app_handle: tauri::AppHandle, args: Vec) -> Result<(), String> { if args.is_empty() || args[0].is_empty() { @@ -37,6 +46,7 @@ pub fn join_path( let joined_path = path.join(args[1..].join("/")); Ok(joined_path.to_string_lossy().to_string()) } + #[tauri::command] pub fn exists_sync( app_handle: tauri::AppHandle,