aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/repair_and_verify
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-08-01 12:28:20 +0200
committerGitHub <noreply@github.com>2023-08-01 12:28:20 +0200
commitfae4de2fba580e4a1a92b853c479b61e856a3a42 (patch)
treefa819d77932fe56f3cfe5e2019a6a8e3c10ab336 /src-tauri/src/repair_and_verify
parent3563a0bc4748b7c14cbff2240af401fab9d4dc5d (diff)
downloadFlightCore-fae4de2fba580e4a1a92b853c479b61e856a3a42.tar.gz
FlightCore-fae4de2fba580e4a1a92b853c479b61e856a3a42.zip
refactor Generalise temporary directory structure (#458)
The temp folder we create could be reused for a lot more things, like extracting Northstar before moving files into the correct place. As such adjust the naming and structure to accommodate this.
Diffstat (limited to 'src-tauri/src/repair_and_verify')
-rw-r--r--src-tauri/src/repair_and_verify/mod.rs34
1 files changed, 19 insertions, 15 deletions
diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs
index 17c71992..29cc9613 100644
--- a/src-tauri/src/repair_and_verify/mod.rs
+++ b/src-tauri/src/repair_and_verify/mod.rs
@@ -40,26 +40,30 @@ pub fn clean_up_download_folder(
game_install: &GameInstall,
force: bool,
) -> Result<(), anyhow::Error> {
- // Get download directory
- let download_directory = format!(
- "{}/___flightcore-temp-download-dir/",
- game_install.game_path
- );
+ const TEMPORARY_DIRECTORIES: [&str; 3] = [
+ "___flightcore-temp-download-dir",
+ "___flightcore-temp/download-dir",
+ "___flightcore-temp",
+ ];
- // Check if files in folder
- let download_dir_contents = std::fs::read_dir(download_directory.clone())?;
- // dbg!(download_dir_contents);
+ for directory in TEMPORARY_DIRECTORIES {
+ // Get download directory
+ let download_directory = format!("{}/{}/", game_install.game_path, directory);
- let mut count = 0;
- download_dir_contents.for_each(|_| count += 1);
+ // Check if files in folder
+ let download_dir_contents = std::fs::read_dir(download_directory.clone())?;
+ // dbg!(download_dir_contents);
- if count > 0 && !force {
- return Err(anyhow!("Folder not empty, not deleting"));
- }
+ let mut count = 0;
+ download_dir_contents.for_each(|_| count += 1);
- // Delete folder
- std::fs::remove_dir_all(download_directory)?;
+ if count > 0 && !force {
+ return Err(anyhow!("Folder not empty, not deleting"));
+ }
+ // Delete folder
+ std::fs::remove_dir_all(download_directory)?;
+ }
Ok(())
}