From 692d87c1cac43c8c082933e4f121cda3926c64b3 Mon Sep 17 00:00:00 2001 From: Rumrobot Date: Sat, 30 Mar 2024 16:11:30 +0100 Subject: [PATCH] Remove old .zip files (And created TODO.md) --- README.md | 2 +- TODO.md | 17 +++++++++++++++++ src-tauri/src/main.rs | 4 ++-- src/routes/+page.svelte | 16 +++++++++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 TODO.md diff --git a/README.md b/README.md index e4892ee..fadbc35 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Pavlov Map Manager GitHub Downloads (all assets, all releases) GitHub last commit - Mod.io Link + Mod.io Link Pavlov VR Steam page diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..e0803c3 --- /dev/null +++ b/TODO.md @@ -0,0 +1,17 @@ +# Todo + +- Clean up the code ofc. +- Fix colors + +## New features + +- Select button for maps +- Cancel button for downloading + + +## Settings + +- Disable the confirm popup on map deletion +- Update all on startup + - Close app when all maps are updated + \ No newline at end of file diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 4b3511b..4171cd2 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -5,7 +5,7 @@ use std::fs; use std::fs::File; #[tauri::command] -fn list_dir(path: String) -> Result, String> { +fn ls(path: String) -> Result, String> { // Read the directory let parsed_path = path.replace("%user%", &whoami::username()); let entries = match fs::read_dir(&parsed_path) { @@ -115,7 +115,7 @@ fn main() { .plugin(tauri_plugin_store::Builder::default().build()) .plugin(tauri_plugin_upload::init()) .invoke_handler(tauri::generate_handler![ - list_dir, + ls, read_file, extract_zip, write_text_file, diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 72af7ba..a40be8d 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -106,7 +106,7 @@ async function getMaps() { const path = await config.get("mods_path"); try { - maps = await invoke("list_dir", { path }); + maps = await invoke("ls", { path }); maps = maps.filter((map: string) => map.startsWith("UGC")); maps = maps.map((map: string) => map.split("UGC")[1]); @@ -505,6 +505,20 @@ } i++; } + + status = "Removing old .zip files"; + try { + const files: Array = await invoke("ls", { + path: "./", + }); + for (const file of files) { + if (file.endsWith(".zip")) { + await removeFile(file); + } + } + } catch (error) { + return; + } } (async () => {