From 86363327a3edb383a84331c702e58a7ea2979938 Mon Sep 17 00:00:00 2001 From: quexeky Date: Fri, 1 Nov 2024 07:49:42 +1100 Subject: [PATCH 1/8] Clippy cleanup Signed-off-by: quexeky --- src-tauri/src/downloads/download_agent.rs | 2 +- src-tauri/src/downloads/download_commands.rs | 4 ++-- src-tauri/src/downloads/download_logic.rs | 23 +------------------- src-tauri/src/downloads/manifest.rs | 2 -- 4 files changed, 4 insertions(+), 27 deletions(-) diff --git a/src-tauri/src/downloads/download_agent.rs b/src-tauri/src/downloads/download_agent.rs index 093f1cc..4c43354 100644 --- a/src-tauri/src/downloads/download_agent.rs +++ b/src-tauri/src/downloads/download_agent.rs @@ -3,7 +3,7 @@ use crate::db::{DatabaseImpls, DATA_ROOT_DIR}; use crate::downloads::download_logic; use crate::downloads::manifest::{DropDownloadContext, DropManifest}; use crate::downloads::progress::ProgressChecker; -use crate::{AppState, DB}; +use crate::DB; use log::info; use rustix::fs::{fallocate, FallocateFlags}; use serde::{Deserialize, Serialize}; diff --git a/src-tauri/src/downloads/download_commands.rs b/src-tauri/src/downloads/download_commands.rs index 550d837..3bae4bb 100644 --- a/src-tauri/src/downloads/download_commands.rs +++ b/src-tauri/src/downloads/download_commands.rs @@ -56,7 +56,7 @@ pub async fn start_game_downloads( } }); info!("Spawned download"); - return Ok(()) + Ok(()) } pub fn start_game_download( @@ -92,5 +92,5 @@ pub async fn stop_specific_game_download(state: tauri::State<'_, Mutex info!("Stopping callback"); callback.store(true, Ordering::Release); - return Ok(()) + Ok(()) } \ No newline at end of file diff --git a/src-tauri/src/downloads/download_logic.rs b/src-tauri/src/downloads/download_logic.rs index d432780..f00cbfc 100644 --- a/src-tauri/src/downloads/download_logic.rs +++ b/src-tauri/src/downloads/download_logic.rs @@ -2,11 +2,10 @@ use crate::auth::generate_authorization_header; use crate::db::DatabaseImpls; use crate::downloads::manifest::DropDownloadContext; use crate::DB; -use gxhash::{gxhash128, GxHasher}; use log::info; use md5::{Context, Digest}; use reqwest::blocking::Response; -use std::{fs::{File, OpenOptions}, hash::Hasher, io::{self, BufReader, BufWriter, Error, ErrorKind, Read, Seek, SeekFrom, Write}, path::PathBuf, sync::{atomic::{AtomicBool, Ordering}, Arc}}; +use std::{fs::{File, OpenOptions}, io::{self, Error, ErrorKind, Read, Seek, SeekFrom, Write}, path::PathBuf, sync::{atomic::{AtomicBool, Ordering}, Arc}}; use urlencoding::encode; pub struct DropFileWriter { @@ -101,24 +100,4 @@ pub fn download_game_chunk(ctx: DropDownloadContext, callback: Arc) } // stream.flush().unwrap(); -} - -pub fn copy_to_drop_file_writer(response: &mut Response, writer: &mut DropFileWriter) { - loop { - info!("Writing to file writer"); - let mut buf = [0u8; 1024]; - response.read(&mut buf).unwrap(); - match writer.write_all(&buf) { - Ok(_) => {}, - Err(e) => { - match e.kind() { - ErrorKind::Interrupted => { - info!("Interrupted"); - return; - } - _ => { println!("{}", e); return;} - } - }, - } - } } \ No newline at end of file diff --git a/src-tauri/src/downloads/manifest.rs b/src-tauri/src/downloads/manifest.rs index 895d3ab..9393f8b 100644 --- a/src-tauri/src/downloads/manifest.rs +++ b/src-tauri/src/downloads/manifest.rs @@ -1,8 +1,6 @@ use serde::{Deserialize, Serialize}; use std::collections::HashMap; -use std::fs::File; use std::path::PathBuf; -use std::sync::{Arc, Mutex}; pub type DropManifest = HashMap; #[derive(Serialize, Deserialize, Debug, Clone, Ord, PartialOrd, Eq, PartialEq)] From bd39f1fd72c00c671057687dc4b1dae69e30b5f9 Mon Sep 17 00:00:00 2001 From: quexeky Date: Fri, 1 Nov 2024 07:51:56 +1100 Subject: [PATCH 2/8] Removed gxhash and ran cargo fmt Signed-off-by: quexeky --- src-tauri/Cargo.lock | 10 --- src-tauri/Cargo.toml | 1 - src-tauri/src/auth.rs | 21 +++--- src-tauri/src/db.rs | 2 +- src-tauri/src/downloads/download_agent.rs | 15 ++--- src-tauri/src/downloads/download_commands.rs | 70 ++++++++++++-------- src-tauri/src/downloads/download_logic.rs | 44 +++++++----- src-tauri/src/downloads/manifest.rs | 2 +- src-tauri/src/downloads/mod.rs | 6 +- src-tauri/src/downloads/progress.rs | 12 ++-- src-tauri/src/lib.rs | 29 ++++---- src-tauri/src/library.rs | 11 ++- src-tauri/src/remote.rs | 2 +- src-tauri/src/tests/mod.rs | 2 +- src-tauri/src/tests/progress_tests.rs | 6 +- 15 files changed, 129 insertions(+), 104 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 9d13bce..520eb1a 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -1021,7 +1021,6 @@ dependencies = [ "ciborium", "directories", "env_logger", - "gxhash", "hex", "http", "log", @@ -1698,15 +1697,6 @@ dependencies = [ "syn 2.0.79", ] -[[package]] -name = "gxhash" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09f0c897148ec6ff3ca864b7c886df75e6ba09972d206bd9a89af0c18c992253" -dependencies = [ - "rand 0.8.5", -] - [[package]] name = "h2" version = "0.4.6" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index b5374cc..79a3d0a 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -45,7 +45,6 @@ tokio = { version = "1.40.0", features = ["rt", "tokio-macros"] } versions = { version = "6.3.2", features = ["serde"] } urlencoding = "2.1.3" rustix = "0.38.37" -gxhash = "2.3.0" md5 = "0.7.0" [dependencies.uuid] diff --git a/src-tauri/src/auth.rs b/src-tauri/src/auth.rs index c27e2e4..4de2277 100644 --- a/src-tauri/src/auth.rs +++ b/src-tauri/src/auth.rs @@ -1,37 +1,36 @@ use std::{ env, - sync::Mutex, time::{SystemTime, UNIX_EPOCH}, + sync::Mutex, + time::{SystemTime, UNIX_EPOCH}, }; use log::{info, warn}; -use openssl::{ - ec::EcKey, - hash::MessageDigest, - pkey::PKey, - sign::{Signer}, -}; +use openssl::{ec::EcKey, hash::MessageDigest, pkey::PKey, sign::Signer}; use serde::{Deserialize, Serialize}; use tauri::{AppHandle, Emitter, Manager}; use url::Url; -use crate::{db::{DatabaseAuth, DatabaseImpls}, AppState, AppStatus, User, DB}; +use crate::{ + db::{DatabaseAuth, DatabaseImpls}, + AppState, AppStatus, User, DB, +}; #[derive(Serialize)] -#[serde(rename_all="camelCase")] +#[serde(rename_all = "camelCase")] struct InitiateRequestBody { name: String, platform: String, } #[derive(Serialize)] -#[serde(rename_all="camelCase")] +#[serde(rename_all = "camelCase")] struct HandshakeRequestBody { client_id: String, token: String, } #[derive(Deserialize)] -#[serde(rename_all="camelCase")] +#[serde(rename_all = "camelCase")] struct HandshakeResponse { private: String, certificate: String, diff --git a/src-tauri/src/db.rs b/src-tauri/src/db.rs index 9cc0695..62c0829 100644 --- a/src-tauri/src/db.rs +++ b/src-tauri/src/db.rs @@ -86,4 +86,4 @@ impl DatabaseImpls for DatabaseInterface { let handle = self.borrow_data().unwrap(); Url::parse(&handle.base_url).unwrap() } -} \ No newline at end of file +} diff --git a/src-tauri/src/downloads/download_agent.rs b/src-tauri/src/downloads/download_agent.rs index 4c43354..792c3b3 100644 --- a/src-tauri/src/downloads/download_agent.rs +++ b/src-tauri/src/downloads/download_agent.rs @@ -7,11 +7,11 @@ use crate::DB; use log::info; use rustix::fs::{fallocate, FallocateFlags}; use serde::{Deserialize, Serialize}; -use urlencoding::encode; use std::fs::{create_dir_all, File}; use std::path::Path; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::sync::{Arc, Mutex}; +use urlencoding::encode; pub struct GameDownloadAgent { pub id: String, @@ -20,7 +20,7 @@ pub struct GameDownloadAgent { contexts: Mutex>, progress: ProgressChecker, pub manifest: Mutex>, - pub callback: Arc + pub callback: Arc, } #[derive(Serialize, Deserialize, Clone, Eq, PartialEq)] pub enum GameDownloadState { @@ -58,7 +58,7 @@ impl GameDownloadAgent { progress: ProgressChecker::new( Box::new(download_logic::download_game_chunk), Arc::new(AtomicUsize::new(0)), - callback + callback, ), contexts: Mutex::new(Vec::new()), } @@ -77,8 +77,7 @@ impl GameDownloadAgent { // It's not necessary, I just can't figure out to make the borrow checker happy { let lock = self.contexts.lock().unwrap().to_vec(); - self.progress - .run_context_parallel(lock, max_threads); + self.progress.run_context_parallel(lock, max_threads); } Ok(()) } @@ -97,7 +96,8 @@ impl GameDownloadAgent { .join( format!( "/api/v1/client/metadata/manifest?id={}&version={}", - self.id, encode(&self.version) + self.id, + encode(&self.version) ) .as_str(), ) @@ -164,7 +164,7 @@ impl GameDownloadAgent { index: i, game_id: game_id.to_string(), path: path.clone(), - checksum: chunk.checksums[i].clone() + checksum: chunk.checksums[i].clone(), }); running_offset += *length as u64; } @@ -183,4 +183,3 @@ impl GameDownloadAgent { Ok(()) } } - diff --git a/src-tauri/src/downloads/download_commands.rs b/src-tauri/src/downloads/download_commands.rs index 3bae4bb..2c93285 100644 --- a/src-tauri/src/downloads/download_commands.rs +++ b/src-tauri/src/downloads/download_commands.rs @@ -1,4 +1,7 @@ -use std::{sync::{atomic::Ordering, Arc, Mutex}, thread}; +use std::{ + sync::{atomic::Ordering, Arc, Mutex}, + thread, +}; use log::info; @@ -13,7 +16,10 @@ pub async fn queue_game_download( state: tauri::State<'_, Mutex>, ) -> Result<(), GameDownloadError> { info!("Queuing Game Download"); - let download_agent = Arc::new(GameDownloadAgent::new(game_id.clone(), game_version.clone())); + let download_agent = Arc::new(GameDownloadAgent::new( + game_id.clone(), + game_version.clone(), + )); download_agent.queue().await?; let mut queue = state.lock().unwrap(); @@ -30,30 +36,28 @@ pub async fn start_game_downloads( let lock = state.lock().unwrap(); let mut game_downloads = lock.game_downloads.clone(); drop(lock); - thread::spawn(move || { - loop { - let mut current_id = String::new(); - let mut download_agent = None; - { - for (id, agent) in &game_downloads { - if agent.get_state() == GameDownloadState::Queued { - download_agent = Some(agent.clone()); - current_id = id.clone(); - info!("Got queued game to download"); - break; - } + thread::spawn(move || loop { + let mut current_id = String::new(); + let mut download_agent = None; + { + for (id, agent) in &game_downloads { + if agent.get_state() == GameDownloadState::Queued { + download_agent = Some(agent.clone()); + current_id = id.clone(); + info!("Got queued game to download"); + break; } - if download_agent.is_none() { - info!("No more games left to download"); - return; - } - }; - info!("Downloading game"); - { - start_game_download(max_threads, download_agent.unwrap()).unwrap(); - game_downloads.remove_entry(¤t_id); } - } + if download_agent.is_none() { + info!("No more games left to download"); + return; + } + }; + info!("Downloading game"); + { + start_game_download(max_threads, download_agent.unwrap()).unwrap(); + game_downloads.remove_entry(¤t_id); + } }); info!("Spawned download"); Ok(()) @@ -61,11 +65,10 @@ pub async fn start_game_downloads( pub fn start_game_download( max_threads: usize, - download_agent: Arc + download_agent: Arc, ) -> Result<(), GameDownloadError> { info!("Triggered Game Download"); - download_agent.ensure_manifest_exists()?; let local_manifest = { @@ -73,7 +76,13 @@ pub fn start_game_download( (*manifest).clone().unwrap() }; - download_agent.generate_job_contexts(&local_manifest, download_agent.version.clone(), download_agent.id.clone()).unwrap(); + download_agent + .generate_job_contexts( + &local_manifest, + download_agent.version.clone(), + download_agent.id.clone(), + ) + .unwrap(); download_agent.begin_download(max_threads).unwrap(); @@ -81,7 +90,10 @@ pub fn start_game_download( } #[tauri::command] -pub async fn stop_specific_game_download(state: tauri::State<'_, Mutex>, game_id: String) -> Result<(), String> { +pub async fn stop_specific_game_download( + state: tauri::State<'_, Mutex>, + game_id: String, +) -> Result<(), String> { info!("called stop_specific_game_download"); let lock = state.lock().unwrap(); let download_agent = lock.game_downloads.get(&game_id).unwrap(); @@ -93,4 +105,4 @@ pub async fn stop_specific_game_download(state: tauri::State<'_, Mutex callback.store(true, Ordering::Release); Ok(()) -} \ No newline at end of file +} diff --git a/src-tauri/src/downloads/download_logic.rs b/src-tauri/src/downloads/download_logic.rs index f00cbfc..c92205e 100644 --- a/src-tauri/src/downloads/download_logic.rs +++ b/src-tauri/src/downloads/download_logic.rs @@ -4,21 +4,28 @@ use crate::downloads::manifest::DropDownloadContext; use crate::DB; use log::info; use md5::{Context, Digest}; -use reqwest::blocking::Response; -use std::{fs::{File, OpenOptions}, io::{self, Error, ErrorKind, Read, Seek, SeekFrom, Write}, path::PathBuf, sync::{atomic::{AtomicBool, Ordering}, Arc}}; +use std::{ + fs::{File, OpenOptions}, + io::{self, Error, ErrorKind, Seek, SeekFrom, Write}, + path::PathBuf, + sync::{ + atomic::{AtomicBool, Ordering}, + Arc, + }, +}; use urlencoding::encode; pub struct DropFileWriter { file: File, hasher: Context, - callback: Arc + callback: Arc, } impl DropFileWriter { fn new(path: PathBuf, callback: Arc) -> Self { Self { file: OpenOptions::new().write(true).open(path).unwrap(), hasher: Context::new(), - callback + callback, } } fn finish(mut self) -> io::Result { @@ -30,9 +37,12 @@ impl DropFileWriter { impl Write for DropFileWriter { fn write(&mut self, buf: &[u8]) -> std::io::Result { if self.callback.load(Ordering::Acquire) { - return Err(Error::new(ErrorKind::ConnectionAborted, "Interrupt command recieved")); + return Err(Error::new( + ErrorKind::ConnectionAborted, + "Interrupt command recieved", + )); } - + //info!("Writing data to writer"); self.hasher.write_all(buf).unwrap(); self.file.write(buf) @@ -78,26 +88,30 @@ pub fn download_game_chunk(ctx: DropDownloadContext, callback: Arc) let mut file: DropFileWriter = DropFileWriter::new(ctx.path, callback); if ctx.offset != 0 { - file - .seek(SeekFrom::Start(ctx.offset)) + file.seek(SeekFrom::Start(ctx.offset)) .expect("Failed to seek to file offset"); } - // Writing everything to disk directly is probably slightly faster because it balances out the writes, + // Writing everything to disk directly is probably slightly faster because it balances out the writes, // but this is better than the performance loss from constantly reading the callbacks //let mut writer = BufWriter::with_capacity(1024 * 1024, file); //copy_to_drop_file_writer(&mut response, &mut file); match io::copy(&mut response, &mut file) { - Ok(_) => {}, - Err(e) => { info!("Copy errored with error {}", e)}, + Ok(_) => {} + Err(e) => { + info!("Copy errored with error {}", e) + } } - + let res = hex::encode(file.finish().unwrap().0); - if res != ctx.checksum { - info!("Checksum failed. Original: {}, Calculated: {} for {}", ctx.checksum, res, ctx.file_name); + if res != ctx.checksum { + info!( + "Checksum failed. Original: {}, Calculated: {} for {}", + ctx.checksum, res, ctx.file_name + ); } // stream.flush().unwrap(); -} \ No newline at end of file +} diff --git a/src-tauri/src/downloads/manifest.rs b/src-tauri/src/downloads/manifest.rs index 9393f8b..2bb1552 100644 --- a/src-tauri/src/downloads/manifest.rs +++ b/src-tauri/src/downloads/manifest.rs @@ -19,5 +19,5 @@ pub struct DropDownloadContext { pub offset: u64, pub game_id: String, pub path: PathBuf, - pub checksum: String + pub checksum: String, } diff --git a/src-tauri/src/downloads/mod.rs b/src-tauri/src/downloads/mod.rs index bfbc2bc..146ed81 100644 --- a/src-tauri/src/downloads/mod.rs +++ b/src-tauri/src/downloads/mod.rs @@ -1,5 +1,5 @@ +pub mod download_agent; +pub mod download_commands; +mod download_logic; mod manifest; pub mod progress; -pub mod download_agent; -mod download_logic; -pub mod download_commands; \ No newline at end of file diff --git a/src-tauri/src/downloads/progress.rs b/src-tauri/src/downloads/progress.rs index 671ba34..18ea179 100644 --- a/src-tauri/src/downloads/progress.rs +++ b/src-tauri/src/downloads/progress.rs @@ -9,7 +9,7 @@ where { counter: Arc, f: Arc) + Send + Sync + 'static>>, - callback: Arc + callback: Arc, } impl ProgressChecker @@ -19,12 +19,12 @@ where pub fn new( f: Box) + Send + Sync + 'static>, counter_reference: Arc, - callback: Arc + callback: Arc, ) -> Self { Self { f: f.into(), counter: counter_reference, - callback + callback, } } pub fn run_contexts_sequentially(&self, contexts: Vec) { @@ -57,11 +57,13 @@ where for context in contexts { let callback = self.callback.clone(); let f = self.f.clone(); - s.spawn(move |_| {info!("Running thread"); f(context, callback)}); + s.spawn(move |_| { + info!("Running thread"); + f(context, callback) + }); } }); info!("Concluded scope"); - } pub fn get_progress(&self) -> usize { self.counter.load(Ordering::Relaxed) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 44198c1..575fcf6 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,27 +1,30 @@ mod auth; mod db; +mod downloads; mod library; mod remote; -mod downloads; #[cfg(test)] mod tests; +use crate::db::DatabaseImpls; +use crate::downloads::download_agent::GameDownloadAgent; use auth::{auth_initiate, generate_authorization_header, recieve_handshake}; use db::{DatabaseInterface, DATA_ROOT_DIR}; -use downloads::download_commands::{queue_game_download, start_game_downloads, stop_specific_game_download}; +use downloads::download_commands::{ + queue_game_download, start_game_downloads, stop_specific_game_download, +}; use env_logger::Env; use http::{header::*, response::Builder as ResponseBuilder}; use library::{fetch_game, fetch_library, Game}; use log::info; use remote::{gen_drop_url, use_remote}; use serde::{Deserialize, Serialize}; -use std::{ - collections::HashMap, sync::{LazyLock, Mutex} -}; use std::sync::Arc; +use std::{ + collections::HashMap, + sync::{LazyLock, Mutex}, +}; use tauri_plugin_deep_link::DeepLinkExt; -use crate::db::DatabaseImpls; -use crate::downloads::download_agent::{GameDownloadAgent}; #[derive(Clone, Copy, Serialize)] pub enum AppStatus { @@ -31,7 +34,7 @@ pub enum AppStatus { SignedInNeedsReauth, } #[derive(Clone, Serialize, Deserialize)] -#[serde(rename_all="camelCase")] +#[serde(rename_all = "camelCase")] pub struct User { id: String, username: String, @@ -41,14 +44,14 @@ pub struct User { } #[derive(Clone, Serialize)] -#[serde(rename_all="camelCase")] +#[serde(rename_all = "camelCase")] pub struct AppState { status: AppStatus, user: Option, games: HashMap, - + #[serde(skip_serializing)] - game_downloads: HashMap> + game_downloads: HashMap>, } #[tauri::command] @@ -144,7 +147,9 @@ pub fn run() { info!("handling drop:// url"); let binding = event.urls(); let url = binding.first().unwrap(); - if url.host_str().unwrap() == "handshake" { recieve_handshake(handle.clone(), url.path().to_string()) } + if url.host_str().unwrap() == "handshake" { + recieve_handshake(handle.clone(), url.path().to_string()) + } }); Ok(()) diff --git a/src-tauri/src/library.rs b/src-tauri/src/library.rs index 1c81870..dfad28d 100644 --- a/src-tauri/src/library.rs +++ b/src-tauri/src/library.rs @@ -4,9 +4,9 @@ use serde::{Deserialize, Serialize}; use serde_json::json; use tauri::{AppHandle, Manager}; -use crate::{auth::generate_authorization_header, AppState, DB}; -use crate::db::DatabaseImpls; use crate::db::DatabaseGameStatus; +use crate::db::DatabaseImpls; +use crate::{auth::generate_authorization_header, AppState, DB}; #[derive(serde::Serialize)] struct FetchGameStruct { @@ -83,7 +83,12 @@ pub fn fetch_game(id: String, app: tauri::AppHandle) -> Result { let data = FetchGameStruct { game: game.clone(), - status: db_handle.games.games_statuses.get(&game.id).unwrap().clone(), + status: db_handle + .games + .games_statuses + .get(&game.id) + .unwrap() + .clone(), }; return Ok(json!(data).to_string()); diff --git a/src-tauri/src/remote.rs b/src-tauri/src/remote.rs index fdf6a73..8b65854 100644 --- a/src-tauri/src/remote.rs +++ b/src-tauri/src/remote.rs @@ -21,7 +21,7 @@ macro_rules! unwrap_or_return { } #[derive(Deserialize)] -#[serde(rename_all="camelCase")] +#[serde(rename_all = "camelCase")] struct DropHealthcheck { app_name: String, } diff --git a/src-tauri/src/tests/mod.rs b/src-tauri/src/tests/mod.rs index 9dff719..401ca7e 100644 --- a/src-tauri/src/tests/mod.rs +++ b/src-tauri/src/tests/mod.rs @@ -1 +1 @@ -mod progress_tests; \ No newline at end of file +mod progress_tests; diff --git a/src-tauri/src/tests/progress_tests.rs b/src-tauri/src/tests/progress_tests.rs index dea2c1f..a3c8e5f 100644 --- a/src-tauri/src/tests/progress_tests.rs +++ b/src-tauri/src/tests/progress_tests.rs @@ -1,6 +1,6 @@ -use std::sync::Arc; -use std::sync::atomic::{AtomicBool, AtomicUsize}; use crate::downloads::progress::ProgressChecker; +use std::sync::atomic::{AtomicBool, AtomicUsize}; +use std::sync::Arc; #[test] fn test_progress_sequentially() { @@ -20,4 +20,4 @@ fn test_progress_parallel() { fn test_fn(int: usize, callback: Arc) { println!("{}", int); -} \ No newline at end of file +} From 0528c780920bfe5972539a7772c20df5a0b21e5c Mon Sep 17 00:00:00 2001 From: quexeky Date: Mon, 4 Nov 2024 17:11:37 +1100 Subject: [PATCH 3/8] Functioning download progress updates Signed-off-by: quexeky --- pages/store/index.vue | 18 ++++++++++ src-tauri/Cargo.lock | 7 ++++ src-tauri/Cargo.toml | 1 + src-tauri/src/downloads/download_agent.rs | 11 ++++-- src-tauri/src/downloads/download_commands.rs | 12 +++++++ src-tauri/src/downloads/download_logic.rs | 13 +++++--- src-tauri/src/downloads/progress.rs | 35 ++++++++++++-------- src-tauri/src/lib.rs | 5 +-- src-tauri/src/tests/progress_tests.rs | 14 ++++---- 9 files changed, 89 insertions(+), 27 deletions(-) diff --git a/pages/store/index.vue b/pages/store/index.vue index 1b3ea21..53db899 100644 --- a/pages/store/index.vue +++ b/pages/store/index.vue @@ -19,6 +19,12 @@ > Cancel game download + diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 520eb1a..e0d8a65 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -298,6 +298,12 @@ dependencies = [ "system-deps", ] +[[package]] +name = "atomic-counter" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62f447d68cfa5a9ab0c1c862a703da2a65b5ed1b7ce1153c9eb0169506d56019" + [[package]] name = "atomic-waker" version = "1.1.2" @@ -1018,6 +1024,7 @@ dependencies = [ name = "drop-app" version = "0.1.0" dependencies = [ + "atomic-counter", "ciborium", "directories", "env_logger", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 79a3d0a..aca911f 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -46,6 +46,7 @@ versions = { version = "6.3.2", features = ["serde"] } urlencoding = "2.1.3" rustix = "0.38.37" md5 = "0.7.0" +atomic-counter = "1.0.1" [dependencies.uuid] version = "1.10.0" diff --git a/src-tauri/src/downloads/download_agent.rs b/src-tauri/src/downloads/download_agent.rs index 792c3b3..43f6322 100644 --- a/src-tauri/src/downloads/download_agent.rs +++ b/src-tauri/src/downloads/download_agent.rs @@ -4,6 +4,7 @@ use crate::downloads::download_logic; use crate::downloads::manifest::{DropDownloadContext, DropManifest}; use crate::downloads::progress::ProgressChecker; use crate::DB; +use atomic_counter::RelaxedCounter; use log::info; use rustix::fs::{fallocate, FallocateFlags}; use serde::{Deserialize, Serialize}; @@ -18,7 +19,7 @@ pub struct GameDownloadAgent { pub version: String, state: Mutex, contexts: Mutex>, - progress: ProgressChecker, + pub progress: ProgressChecker, pub manifest: Mutex>, pub callback: Arc, } @@ -57,8 +58,9 @@ impl GameDownloadAgent { callback: callback.clone(), progress: ProgressChecker::new( Box::new(download_logic::download_game_chunk), - Arc::new(AtomicUsize::new(0)), + Arc::new(RelaxedCounter::new(0)), callback, + 0 ), contexts: Mutex::new(Vec::new()), } @@ -119,11 +121,16 @@ impl GameDownloadAgent { } let manifest_download = response.json::().unwrap(); + let length = manifest_download.iter().map(|(_, chunk)| { + return chunk.lengths.iter().sum::(); + }).sum::(); + self.progress.set_capacity(length); if let Ok(mut manifest) = self.manifest.lock() { *manifest = Some(manifest_download) } else { return Err(GameDownloadError::System(SystemError::MutexLockFailed)); } + Ok(()) } diff --git a/src-tauri/src/downloads/download_commands.rs b/src-tauri/src/downloads/download_commands.rs index 2c93285..cb49237 100644 --- a/src-tauri/src/downloads/download_commands.rs +++ b/src-tauri/src/downloads/download_commands.rs @@ -106,3 +106,15 @@ pub async fn stop_specific_game_download( Ok(()) } + +#[tauri::command] +pub async fn get_game_download_progress( + state: tauri::State<'_, Mutex>, + game_id: String +) -> Result { + let lock = state.lock().unwrap(); + let download_agent = lock.game_downloads.get(&game_id).unwrap(); + let progress = download_agent.progress.get_progress_percentage(); + info!("{}", progress); + return Ok(progress) +} \ No newline at end of file diff --git a/src-tauri/src/downloads/download_logic.rs b/src-tauri/src/downloads/download_logic.rs index c92205e..fee6c9b 100644 --- a/src-tauri/src/downloads/download_logic.rs +++ b/src-tauri/src/downloads/download_logic.rs @@ -2,6 +2,7 @@ use crate::auth::generate_authorization_header; use crate::db::DatabaseImpls; use crate::downloads::manifest::DropDownloadContext; use crate::DB; +use atomic_counter::{AtomicCounter, RelaxedCounter}; use log::info; use md5::{Context, Digest}; use std::{ @@ -9,7 +10,7 @@ use std::{ io::{self, Error, ErrorKind, Seek, SeekFrom, Write}, path::PathBuf, sync::{ - atomic::{AtomicBool, Ordering}, + atomic::{AtomicBool, AtomicUsize, Ordering}, Arc, }, }; @@ -19,13 +20,15 @@ pub struct DropFileWriter { file: File, hasher: Context, callback: Arc, + progress: Arc } impl DropFileWriter { - fn new(path: PathBuf, callback: Arc) -> Self { + fn new(path: PathBuf, callback: Arc, progress: Arc) -> Self { Self { file: OpenOptions::new().write(true).open(path).unwrap(), hasher: Context::new(), callback, + progress } } fn finish(mut self) -> io::Result { @@ -42,6 +45,8 @@ impl Write for DropFileWriter { "Interrupt command recieved", )); } + let len = buf.len(); + self.progress.add(len); //info!("Writing data to writer"); self.hasher.write_all(buf).unwrap(); @@ -58,7 +63,7 @@ impl Seek for DropFileWriter { self.file.seek(pos) } } -pub fn download_game_chunk(ctx: DropDownloadContext, callback: Arc) { +pub fn download_game_chunk(ctx: DropDownloadContext, callback: Arc, progress: Arc) { if callback.load(Ordering::Acquire) { info!("Callback stopped download at start"); return; @@ -85,7 +90,7 @@ pub fn download_game_chunk(ctx: DropDownloadContext, callback: Arc) .send() .unwrap(); - let mut file: DropFileWriter = DropFileWriter::new(ctx.path, callback); + let mut file: DropFileWriter = DropFileWriter::new(ctx.path, callback, progress); if ctx.offset != 0 { file.seek(SeekFrom::Start(ctx.offset)) diff --git a/src-tauri/src/downloads/progress.rs b/src-tauri/src/downloads/progress.rs index 18ea179..e217f56 100644 --- a/src-tauri/src/downloads/progress.rs +++ b/src-tauri/src/downloads/progress.rs @@ -1,15 +1,17 @@ +use atomic_counter::{AtomicCounter, RelaxedCounter}; use log::info; use rayon::ThreadPoolBuilder; use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; -use std::sync::Arc; +use std::sync::{Arc, Mutex}; pub struct ProgressChecker where T: 'static + Send + Sync, { - counter: Arc, - f: Arc) + Send + Sync + 'static>>, + counter: Arc, + f: Arc, Arc) + Send + Sync + 'static>>, callback: Arc, + capacity: Mutex } impl ProgressChecker @@ -17,20 +19,21 @@ where T: Send + Sync, { pub fn new( - f: Box) + Send + Sync + 'static>, - counter_reference: Arc, + f: Box, Arc) + Send + Sync + 'static>, + counter: Arc, callback: Arc, + capacity: usize ) -> Self { Self { f: f.into(), - counter: counter_reference, + counter, callback, + capacity: capacity.into() } } pub fn run_contexts_sequentially(&self, contexts: Vec) { for context in contexts { - (self.f)(context, self.callback.clone()); - self.counter.fetch_add(1, Ordering::Release); + (self.f)(context, self.callback.clone(), self.counter.clone()); } } pub fn run_contexts_parallel_background(&self, contexts: Vec, max_threads: usize) { @@ -43,8 +46,9 @@ where for context in contexts { let callback = self.callback.clone(); + let counter = self.counter.clone(); let f = self.f.clone(); - threads.spawn(move || f(context, callback)); + threads.spawn(move || f(context, callback, counter)); } } pub fn run_context_parallel(&self, contexts: Vec, max_threads: usize) { @@ -56,20 +60,25 @@ where threads.scope(|s| { for context in contexts { let callback = self.callback.clone(); + let counter = self.counter.clone(); let f = self.f.clone(); s.spawn(move |_| { info!("Running thread"); - f(context, callback) + f(context, callback, counter) }); } }); info!("Concluded scope"); } + pub fn set_capacity(&self, capacity: usize) { + let mut lock = self.capacity.lock().unwrap(); + *lock = capacity; + } pub fn get_progress(&self) -> usize { - self.counter.load(Ordering::Relaxed) + self.counter.get() } // I strongly dislike type casting in my own code, so I've shovelled it into here - pub fn get_progress_percentage>(&self, capacity: C) -> f64 { - (self.get_progress() as f64) / (capacity.into()) + pub fn get_progress_percentage(&self) -> f64 { + (self.get_progress() as f64) / (*self.capacity.lock().unwrap() as f64) } } diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 575fcf6..a64595a 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -11,7 +11,7 @@ use crate::downloads::download_agent::GameDownloadAgent; use auth::{auth_initiate, generate_authorization_header, recieve_handshake}; use db::{DatabaseInterface, DATA_ROOT_DIR}; use downloads::download_commands::{ - queue_game_download, start_game_downloads, stop_specific_game_download, + get_game_download_progress, queue_game_download, start_game_downloads, stop_specific_game_download }; use env_logger::Env; use http::{header::*, response::Builder as ResponseBuilder}; @@ -117,7 +117,8 @@ pub fn run() { // Downloads queue_game_download, start_game_downloads, - stop_specific_game_download + stop_specific_game_download, + get_game_download_progress ]) .plugin(tauri_plugin_shell::init()) .setup(|app| { diff --git a/src-tauri/src/tests/progress_tests.rs b/src-tauri/src/tests/progress_tests.rs index a3c8e5f..b855c9c 100644 --- a/src-tauri/src/tests/progress_tests.rs +++ b/src-tauri/src/tests/progress_tests.rs @@ -1,23 +1,25 @@ +use atomic_counter::RelaxedCounter; + use crate::downloads::progress::ProgressChecker; use std::sync::atomic::{AtomicBool, AtomicUsize}; use std::sync::Arc; #[test] fn test_progress_sequentially() { - let counter = Arc::new(AtomicUsize::new(0)); + let counter = Arc::new(RelaxedCounter::new(0)); let callback = Arc::new(AtomicBool::new(false)); - let p = ProgressChecker::new(Box::new(test_fn), counter.clone(), callback); + let p = ProgressChecker::new(Box::new(test_fn), counter.clone(), callback, 100); p.run_contexts_sequentially((1..100).collect()); - println!("Progress: {}", p.get_progress_percentage(100)); + println!("Progress: {}", p.get_progress_percentage()); } #[test] fn test_progress_parallel() { - let counter = Arc::new(AtomicUsize::new(0)); + let counter = Arc::new(RelaxedCounter::new(0)); let callback = Arc::new(AtomicBool::new(false)); - let p = ProgressChecker::new(Box::new(test_fn), counter.clone(), callback); + let p = ProgressChecker::new(Box::new(test_fn), counter.clone(), callback, 100); p.run_contexts_parallel_background((1..100).collect(), 10); } -fn test_fn(int: usize, callback: Arc) { +fn test_fn(int: usize, callback: Arc, counter: Arc) { println!("{}", int); } From d887f7316384a75799230c3b9351033f052f48f7 Mon Sep 17 00:00:00 2001 From: quexeky Date: Mon, 4 Nov 2024 17:45:46 +1100 Subject: [PATCH 4/8] Converted to using BufWriters instead of streaming everything at once Signed-off-by: quexeky --- src-tauri/src/downloads/download_logic.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src-tauri/src/downloads/download_logic.rs b/src-tauri/src/downloads/download_logic.rs index fee6c9b..b9b5f7f 100644 --- a/src-tauri/src/downloads/download_logic.rs +++ b/src-tauri/src/downloads/download_logic.rs @@ -3,11 +3,11 @@ use crate::db::DatabaseImpls; use crate::downloads::manifest::DropDownloadContext; use crate::DB; use atomic_counter::{AtomicCounter, RelaxedCounter}; -use log::info; +use log::{error, info}; use md5::{Context, Digest}; use std::{ fs::{File, OpenOptions}, - io::{self, Error, ErrorKind, Seek, SeekFrom, Write}, + io::{self, BufWriter, Error, ErrorKind, Seek, SeekFrom, Write}, path::PathBuf, sync::{ atomic::{AtomicBool, AtomicUsize, Ordering}, @@ -100,15 +100,19 @@ pub fn download_game_chunk(ctx: DropDownloadContext, callback: Arc, // Writing everything to disk directly is probably slightly faster because it balances out the writes, // but this is better than the performance loss from constantly reading the callbacks - //let mut writer = BufWriter::with_capacity(1024 * 1024, file); + let mut writer = BufWriter::with_capacity(1024 * 1024, file); //copy_to_drop_file_writer(&mut response, &mut file); - match io::copy(&mut response, &mut file) { + match io::copy(&mut response, &mut writer) { Ok(_) => {} Err(e) => { info!("Copy errored with error {}", e) } } + let file = match writer.into_inner() { + Ok(file) => file, + Err(_) => {error!("Failed to acquire writer from BufWriter"); return; } + }; let res = hex::encode(file.finish().unwrap().0); if res != ctx.checksum { From 201c8a4e7bf81ad703fb1f76691286250fc797e3 Mon Sep 17 00:00:00 2001 From: quexeky Date: Mon, 4 Nov 2024 17:48:44 +1100 Subject: [PATCH 5/8] Ran cargo clippy and cargo fmt Signed-off-by: quexeky --- src-tauri/src/downloads/download_agent.rs | 14 ++++++++------ src-tauri/src/downloads/download_commands.rs | 6 +++--- src-tauri/src/downloads/download_logic.rs | 17 ++++++++++++----- src-tauri/src/downloads/progress.rs | 8 ++++---- src-tauri/src/lib.rs | 3 ++- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src-tauri/src/downloads/download_agent.rs b/src-tauri/src/downloads/download_agent.rs index 43f6322..cae4a83 100644 --- a/src-tauri/src/downloads/download_agent.rs +++ b/src-tauri/src/downloads/download_agent.rs @@ -10,7 +10,7 @@ use rustix::fs::{fallocate, FallocateFlags}; use serde::{Deserialize, Serialize}; use std::fs::{create_dir_all, File}; use std::path::Path; -use std::sync::atomic::{AtomicBool, AtomicUsize}; +use std::sync::atomic::AtomicBool; use std::sync::{Arc, Mutex}; use urlencoding::encode; @@ -60,7 +60,7 @@ impl GameDownloadAgent { Box::new(download_logic::download_game_chunk), Arc::new(RelaxedCounter::new(0)), callback, - 0 + 0, ), contexts: Mutex::new(Vec::new()), } @@ -121,16 +121,18 @@ impl GameDownloadAgent { } let manifest_download = response.json::().unwrap(); - let length = manifest_download.iter().map(|(_, chunk)| { - return chunk.lengths.iter().sum::(); - }).sum::(); + let length = manifest_download + .values() + .map(|chunk| { + return chunk.lengths.iter().sum::(); + }) + .sum::(); self.progress.set_capacity(length); if let Ok(mut manifest) = self.manifest.lock() { *manifest = Some(manifest_download) } else { return Err(GameDownloadError::System(SystemError::MutexLockFailed)); } - Ok(()) } diff --git a/src-tauri/src/downloads/download_commands.rs b/src-tauri/src/downloads/download_commands.rs index cb49237..064bc55 100644 --- a/src-tauri/src/downloads/download_commands.rs +++ b/src-tauri/src/downloads/download_commands.rs @@ -110,11 +110,11 @@ pub async fn stop_specific_game_download( #[tauri::command] pub async fn get_game_download_progress( state: tauri::State<'_, Mutex>, - game_id: String + game_id: String, ) -> Result { let lock = state.lock().unwrap(); let download_agent = lock.game_downloads.get(&game_id).unwrap(); let progress = download_agent.progress.get_progress_percentage(); info!("{}", progress); - return Ok(progress) -} \ No newline at end of file + Ok(progress) +} diff --git a/src-tauri/src/downloads/download_logic.rs b/src-tauri/src/downloads/download_logic.rs index b9b5f7f..121a844 100644 --- a/src-tauri/src/downloads/download_logic.rs +++ b/src-tauri/src/downloads/download_logic.rs @@ -10,7 +10,7 @@ use std::{ io::{self, BufWriter, Error, ErrorKind, Seek, SeekFrom, Write}, path::PathBuf, sync::{ - atomic::{AtomicBool, AtomicUsize, Ordering}, + atomic::{AtomicBool, Ordering}, Arc, }, }; @@ -20,7 +20,7 @@ pub struct DropFileWriter { file: File, hasher: Context, callback: Arc, - progress: Arc + progress: Arc, } impl DropFileWriter { fn new(path: PathBuf, callback: Arc, progress: Arc) -> Self { @@ -28,7 +28,7 @@ impl DropFileWriter { file: OpenOptions::new().write(true).open(path).unwrap(), hasher: Context::new(), callback, - progress + progress, } } fn finish(mut self) -> io::Result { @@ -63,7 +63,11 @@ impl Seek for DropFileWriter { self.file.seek(pos) } } -pub fn download_game_chunk(ctx: DropDownloadContext, callback: Arc, progress: Arc) { +pub fn download_game_chunk( + ctx: DropDownloadContext, + callback: Arc, + progress: Arc, +) { if callback.load(Ordering::Acquire) { info!("Callback stopped download at start"); return; @@ -111,7 +115,10 @@ pub fn download_game_chunk(ctx: DropDownloadContext, callback: Arc, } let file = match writer.into_inner() { Ok(file) => file, - Err(_) => {error!("Failed to acquire writer from BufWriter"); return; } + Err(_) => { + error!("Failed to acquire writer from BufWriter"); + return; + } }; let res = hex::encode(file.finish().unwrap().0); diff --git a/src-tauri/src/downloads/progress.rs b/src-tauri/src/downloads/progress.rs index e217f56..4511558 100644 --- a/src-tauri/src/downloads/progress.rs +++ b/src-tauri/src/downloads/progress.rs @@ -1,7 +1,7 @@ use atomic_counter::{AtomicCounter, RelaxedCounter}; use log::info; use rayon::ThreadPoolBuilder; -use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use std::sync::atomic::AtomicBool; use std::sync::{Arc, Mutex}; pub struct ProgressChecker @@ -11,7 +11,7 @@ where counter: Arc, f: Arc, Arc) + Send + Sync + 'static>>, callback: Arc, - capacity: Mutex + capacity: Mutex, } impl ProgressChecker @@ -22,13 +22,13 @@ where f: Box, Arc) + Send + Sync + 'static>, counter: Arc, callback: Arc, - capacity: usize + capacity: usize, ) -> Self { Self { f: f.into(), counter, callback, - capacity: capacity.into() + capacity: capacity.into(), } } pub fn run_contexts_sequentially(&self, contexts: Vec) { diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index a64595a..c8806ef 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -11,7 +11,8 @@ use crate::downloads::download_agent::GameDownloadAgent; use auth::{auth_initiate, generate_authorization_header, recieve_handshake}; use db::{DatabaseInterface, DATA_ROOT_DIR}; use downloads::download_commands::{ - get_game_download_progress, queue_game_download, start_game_downloads, stop_specific_game_download + get_game_download_progress, queue_game_download, start_game_downloads, + stop_specific_game_download, }; use env_logger::Env; use http::{header::*, response::Builder as ResponseBuilder}; From 191e62c500132953ae57e46bb1e9f7b15f23daef Mon Sep 17 00:00:00 2001 From: quexeky Date: Mon, 4 Nov 2024 18:03:18 +1100 Subject: [PATCH 6/8] Allowing some dead code features because they are there for future use (potentially) Signed-off-by: quexeky --- src-tauri/src/downloads/progress.rs | 2 ++ src-tauri/src/lib.rs | 1 + src-tauri/src/tests/progress_tests.rs | 4 ++-- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src-tauri/src/downloads/progress.rs b/src-tauri/src/downloads/progress.rs index 4511558..720a05e 100644 --- a/src-tauri/src/downloads/progress.rs +++ b/src-tauri/src/downloads/progress.rs @@ -31,11 +31,13 @@ where capacity: capacity.into(), } } + #[allow(dead_code)] pub fn run_contexts_sequentially(&self, contexts: Vec) { for context in contexts { (self.f)(context, self.callback.clone(), self.counter.clone()); } } + #[allow(dead_code)] pub fn run_contexts_parallel_background(&self, contexts: Vec, max_threads: usize) { let threads = ThreadPoolBuilder::new() // If max_threads == 0, then the limit will be determined diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index c8806ef..9de8857 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -95,6 +95,7 @@ pub fn run() { let mut builder = tauri::Builder::default().plugin(tauri_plugin_dialog::init()); #[cfg(desktop)] + #[allow(unused_variables)] { builder = builder.plugin(tauri_plugin_single_instance::init(|_app, argv, _cwd| { // when defining deep link schemes at runtime, you must also check `argv` here diff --git a/src-tauri/src/tests/progress_tests.rs b/src-tauri/src/tests/progress_tests.rs index b855c9c..1d2df40 100644 --- a/src-tauri/src/tests/progress_tests.rs +++ b/src-tauri/src/tests/progress_tests.rs @@ -1,7 +1,7 @@ use atomic_counter::RelaxedCounter; use crate::downloads::progress::ProgressChecker; -use std::sync::atomic::{AtomicBool, AtomicUsize}; +use std::sync::atomic::AtomicBool; use std::sync::Arc; #[test] @@ -20,6 +20,6 @@ fn test_progress_parallel() { p.run_contexts_parallel_background((1..100).collect(), 10); } -fn test_fn(int: usize, callback: Arc, counter: Arc) { +fn test_fn(int: usize, _callback: Arc, _counter: Arc) { println!("{}", int); } From 49184af96b52c2d724cecbfc098c07ea26b9f663 Mon Sep 17 00:00:00 2001 From: quexeky Date: Mon, 4 Nov 2024 18:47:50 +1100 Subject: [PATCH 7/8] Removed unnecessary dependencies Signed-off-by: quexeky --- src-tauri/Cargo.lock | 217 ------------------------------------------- src-tauri/Cargo.toml | 3 - 2 files changed, 220 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index e0d8a65..c67067b 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -586,33 +586,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "ciborium" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" -dependencies = [ - "ciborium-io", - "ciborium-ll", - "serde", -] - -[[package]] -name = "ciborium-io" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" - -[[package]] -name = "ciborium-ll" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" -dependencies = [ - "ciborium-io", - "half", -] - [[package]] name = "cocoa" version = "0.26.0" @@ -1025,7 +998,6 @@ name = "drop-app" version = "0.1.0" dependencies = [ "atomic-counter", - "ciborium", "directories", "env_logger", "hex", @@ -1039,7 +1011,6 @@ dependencies = [ "rustix", "serde", "serde_json", - "structured-logger", "tauri", "tauri-build", "tauri-plugin-deep-link", @@ -1050,7 +1021,6 @@ dependencies = [ "url", "urlencoding", "uuid", - "versions", "webbrowser", ] @@ -1723,16 +1693,6 @@ dependencies = [ "tracing", ] -[[package]] -name = "half" -version = "2.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" -dependencies = [ - "cfg-if", - "crunchy", -] - [[package]] name = "hashbrown" version = "0.12.3" @@ -2042,15 +2002,6 @@ version = "1.70.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" -[[package]] -name = "itertools" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "413ee7dfc52ee1a4949ceeb7dbc8a33f2d6c088194d9f922fb8318faf1f01186" -dependencies = [ - "either", -] - [[package]] name = "itoa" version = "0.4.8" @@ -2241,10 +2192,6 @@ name = "log" version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" -dependencies = [ - "serde", - "value-bag", -] [[package]] name = "mac" @@ -2308,12 +2255,6 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" -[[package]] -name = "minimal-lexical" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -2427,16 +2368,6 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" -[[package]] -name = "nom" -version = "7.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" -dependencies = [ - "memchr", - "minimal-lexical", -] - [[package]] name = "num-conv" version = "0.1.0" @@ -3581,15 +3512,6 @@ dependencies = [ "syn 2.0.79", ] -[[package]] -name = "serde_fmt" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1d4ddca14104cd60529e8c7f7ba71a2c8acd8f7f5cfcdc2faf97eeb7c3010a4" -dependencies = [ - "serde", -] - [[package]] name = "serde_json" version = "1.0.128" @@ -3878,103 +3800,12 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" -[[package]] -name = "structured-logger" -version = "1.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16524b1ef57fd2e253216ab20ec44f0dc32b29155a4b3e6bef0a857d8c9f5f08" -dependencies = [ - "log", - "parking_lot", - "serde", - "serde_json", - "tokio", -] - [[package]] name = "subtle" version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" -[[package]] -name = "sval" -version = "2.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf38d1fa2ce984086ea42fb856a9f374d94680a4f796831a7fc868d7f2af1b9" - -[[package]] -name = "sval_buffer" -version = "2.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81682ff859964ca1d7cf3d3d0f9ec7204ea04c2c32acb8cc2cf68ecbd3127354" -dependencies = [ - "sval", - "sval_ref", -] - -[[package]] -name = "sval_dynamic" -version = "2.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a213b93bb4c6f4c9f9b17f2e740e077fd18746bbf7c80c72bbadcac68fa7ee4" -dependencies = [ - "sval", -] - -[[package]] -name = "sval_fmt" -version = "2.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6902c6d3fb52c89206fe0dc93546c0123f7d48b5997fd14e61c9e64ff0b63275" -dependencies = [ - "itoa 1.0.11", - "ryu", - "sval", -] - -[[package]] -name = "sval_json" -version = "2.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11a28041ea78cdc394b930ae6b897d36246dc240a29a6edf82d76562487fb0b4" -dependencies = [ - "itoa 1.0.11", - "ryu", - "sval", -] - -[[package]] -name = "sval_nested" -version = "2.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "850346e4b0742a7f2fd2697d703ff80084d0b658f0f2e336d71b8a06abf9b68e" -dependencies = [ - "sval", - "sval_buffer", - "sval_ref", -] - -[[package]] -name = "sval_ref" -version = "2.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "824afd97a8919f28a35b0fdea979845cc2ae461a8a3aaa129455cb89c88bb77a" -dependencies = [ - "sval", -] - -[[package]] -name = "sval_serde" -version = "2.13.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ada7520dd719ed672c786c7db7de4f5230f4d504b0821bd8305cd30ca442315" -dependencies = [ - "serde", - "sval", - "sval_nested", -] - [[package]] name = "swift-rs" version = "1.0.7" @@ -4539,7 +4370,6 @@ dependencies = [ "bytes", "libc", "mio", - "parking_lot", "pin-project-lite", "signal-hook-registry", "socket2", @@ -4884,42 +4714,6 @@ dependencies = [ "syn 2.0.79", ] -[[package]] -name = "value-bag" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a84c137d37ab0142f0f2ddfe332651fdbf252e7b7dbb4e67b6c1f1b2e925101" -dependencies = [ - "value-bag-serde1", - "value-bag-sval2", -] - -[[package]] -name = "value-bag-serde1" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ccacf50c5cb077a9abb723c5bcb5e0754c1a433f1e1de89edc328e2760b6328b" -dependencies = [ - "erased-serde", - "serde", - "serde_fmt", -] - -[[package]] -name = "value-bag-sval2" -version = "1.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1785bae486022dfb9703915d42287dcb284c1ee37bd1080eeba78cc04721285b" -dependencies = [ - "sval", - "sval_buffer", - "sval_dynamic", - "sval_fmt", - "sval_json", - "sval_ref", - "sval_serde", -] - [[package]] name = "vcpkg" version = "0.2.15" @@ -4938,17 +4732,6 @@ version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" -[[package]] -name = "versions" -version = "6.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f25d498b63d1fdb376b4250f39ab3a5ee8d103957346abacd911e2d8b612c139" -dependencies = [ - "itertools", - "nom", - "serde", -] - [[package]] name = "vswhom" version = "0.1.0" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index aca911f..5b7706a 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -29,20 +29,17 @@ tauri = { version = "2.0.0", features = [] } tauri-plugin-shell = "2.0.0" serde = { version = "1", features = ["derive", "rc"] } serde_json = "1" -ciborium = "0.2.2" rayon = "1.10.0" directories = "5.0.1" webbrowser = "1.0.2" url = "2.5.2" tauri-plugin-deep-link = "2" log = "0.4.22" -structured-logger = "1.0.3" hex = "0.4.3" tauri-plugin-dialog = "2" env_logger = "0.11.5" http = "1.1.0" tokio = { version = "1.40.0", features = ["rt", "tokio-macros"] } -versions = { version = "6.3.2", features = ["serde"] } urlencoding = "2.1.3" rustix = "0.38.37" md5 = "0.7.0" From 251e880507e63640e20c5f950943b48b8fb3c042 Mon Sep 17 00:00:00 2001 From: quexeky Date: Mon, 4 Nov 2024 18:48:00 +1100 Subject: [PATCH 8/8] Updated README.md Signed-off-by: quexeky --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d941967..54ceace 100644 --- a/README.md +++ b/README.md @@ -13,4 +13,4 @@ To manually specify the logging level, add the environment variable `RUST_LOG=[d e.g. `RUST_LOG=debug yarn taudi dev` ## Contributing -Check the original Drop repo for contributing guidelines. \ No newline at end of file +Check the original [Drop repo](https://github.com/Drop-OSS/drop) for contributing guidelines. \ No newline at end of file