diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index d5204517..0a372ce6 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1065,6 +1065,7 @@ dependencies = [ "shakmaty", "specta", "strsim", + "tar", "tauri", "tauri-build", "tauri-plugin-log", @@ -2106,9 +2107,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.146" +version = "0.2.149" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92be4933c13fd498862a9e02a3055f8a8d9c039ce33db97306fd5a6caa7f29b" +checksum = "a08173bc88b7955d1b3145aa561539096c421ac8debde8cbc3612ec635fee29b" [[package]] name = "libsqlite3-sys" @@ -4033,9 +4034,9 @@ dependencies = [ [[package]] name = "tar" -version = "0.4.38" +version = "0.4.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b55807c0344e1e6c04d7c965f5289c39a8d94ae23ed5c0b57aabac549f871c6" +checksum = "b16afcea1f22891c49a00c751c7b63b2233284064f11a200fc624137c51e2ddb" dependencies = [ "filetime", "libc", @@ -5427,9 +5428,9 @@ dependencies = [ [[package]] name = "xattr" -version = "0.2.3" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d1526bbe5aaeb5eb06885f4d987bcdfa5e23187055de9b83fe00156a821fabc" +checksum = "f4686009f71ff3e5c4dbcf1a282d0a44db3f021ba69350cd42086b3e5f1c6985" dependencies = [ "libc", ] diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 2864b5e2..1d8eb63a 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -51,6 +51,7 @@ thiserror = "1.0.48" log = "0.4.20" oauth2 = "4.4.2" axum = "0.6.20" +tar = "0.4.40" [features] # by default Tauri runs in production mode diff --git a/src-tauri/src/fide.rs b/src-tauri/src/fide.rs index 4bacb538..41e159c8 100644 --- a/src-tauri/src/fide.rs +++ b/src-tauri/src/fide.rs @@ -96,7 +96,6 @@ pub async fn download_fide_db( 0, "http://ratings.fide.com/download/players_list_xml.zip".to_string(), app_config_dir(&app.config()).unwrap(), - true, app.clone(), None, Some(false), diff --git a/src-tauri/src/fs.rs b/src-tauri/src/fs.rs index 0db4ff20..e3736c66 100644 --- a/src-tauri/src/fs.rs +++ b/src-tauri/src/fs.rs @@ -26,7 +26,6 @@ pub async fn download_file( id: u64, url: String, path: PathBuf, - zip: bool, app: tauri::AppHandle, token: Option, finalize: Option, @@ -71,11 +70,15 @@ pub async fn download_file( info!("Downloaded file to {}", path.display()); - if zip { + if url.ends_with(".zip") { unzip_file(path, file).await?; + } else if url.ends_with(".tar") { + let mut archive = tar::Archive::new(Cursor::new(file)); + archive.unpack(path)?; } else { - std::fs::write(path, file)?; + std::fs::write(path, file)? } + if finalize { app.emit_all( "download_progress", diff --git a/src/components/databases/AddDatabase.tsx b/src/components/databases/AddDatabase.tsx index 437c4ac3..d6830204 100644 --- a/src/components/databases/AddDatabase.tsx +++ b/src/components/databases/AddDatabase.tsx @@ -201,7 +201,6 @@ function DatabaseCard({ await invoke("download_file", { id, url, - zip: false, path, }); setDatabases(await getDatabases()); diff --git a/src/components/engines/AddEngine.tsx b/src/components/engines/AddEngine.tsx index d041b4c0..1c1ea1b0 100644 --- a/src/components/engines/AddEngine.tsx +++ b/src/components/engines/AddEngine.tsx @@ -154,7 +154,6 @@ function EngineCard({ await invoke("download_file", { id, url, - zip: true, path, }); let appDataDirPath = await appDataDir(); diff --git a/src/components/puzzles/AddPuzzle.tsx b/src/components/puzzles/AddPuzzle.tsx index 93622537..fdf9f877 100644 --- a/src/components/puzzles/AddPuzzle.tsx +++ b/src/components/puzzles/AddPuzzle.tsx @@ -112,7 +112,6 @@ function PuzzleDbCard({ await invoke("download_file", { id, url, - zip: false, path, }); setPuzzleDbs(await getPuzzleDatabases()); diff --git a/src/utils/lichess.tsx b/src/utils/lichess.tsx index 6b975356..9bf2ff4b 100644 --- a/src/utils/lichess.tsx +++ b/src/utils/lichess.tsx @@ -227,7 +227,6 @@ export async function downloadLichess( await invoke("download_file", { id: 1, url, - zip: false, path, token, });