diff --git a/src-tauri/src/autostart.rs b/src-tauri/src/client/autostart.rs similarity index 100% rename from src-tauri/src/autostart.rs rename to src-tauri/src/client/autostart.rs diff --git a/src-tauri/src/cleanup.rs b/src-tauri/src/client/cleanup.rs similarity index 100% rename from src-tauri/src/cleanup.rs rename to src-tauri/src/client/cleanup.rs diff --git a/src-tauri/src/commands.rs b/src-tauri/src/client/commands.rs similarity index 100% rename from src-tauri/src/commands.rs rename to src-tauri/src/client/commands.rs diff --git a/src-tauri/src/client/mod.rs b/src-tauri/src/client/mod.rs new file mode 100644 index 0000000..6462889 --- /dev/null +++ b/src-tauri/src/client/mod.rs @@ -0,0 +1,3 @@ +pub mod autostart; +pub mod cleanup; +pub mod commands; \ No newline at end of file diff --git a/src-tauri/src/database/commands.rs b/src-tauri/src/database/commands.rs index 8c56cc4..e7ccd5c 100644 --- a/src-tauri/src/database/commands.rs +++ b/src-tauri/src/database/commands.rs @@ -6,14 +6,12 @@ use std::{ use serde_json::Value; -use crate::{ - database::{db::borrow_db_mut_checked}, - download_manager::internal_error::InternalError, -}; +use crate::{database::db::borrow_db_mut_checked, error::download_manager_error::DownloadManagerError}; use super::{ db::{borrow_db_checked, save_db, DATA_ROOT_DIR}, - debug::SystemData, models::data::Settings, + debug::SystemData, + models::data::Settings, }; // Will, in future, return disk/remaining size @@ -33,7 +31,7 @@ pub fn delete_download_dir(index: usize) { } #[tauri::command] -pub fn add_download_dir(new_dir: PathBuf) -> Result<(), InternalError<()>> { +pub fn add_download_dir(new_dir: PathBuf) -> Result<(), DownloadManagerError<()>> { // Check the new directory is all good let new_dir_path = Path::new(&new_dir); if new_dir_path.exists() { diff --git a/src-tauri/src/database/db.rs b/src-tauri/src/database/db.rs index 7566519..37ee852 100644 --- a/src-tauri/src/database/db.rs +++ b/src-tauri/src/database/db.rs @@ -1,8 +1,6 @@ use std::{ - collections::HashMap, fs::{self, create_dir_all}, - hash::Hash, - path::{Path, PathBuf}, + path::PathBuf, sync::{LazyLock, Mutex, RwLockReadGuard, RwLockWriteGuard}, }; @@ -10,14 +8,12 @@ use chrono::Utc; use directories::BaseDirs; use log::{debug, error, info}; use rustbreak::{DeSerError, DeSerializer, PathDatabase, RustbreakError}; -use serde::{de::DeserializeOwned, Deserialize, Serialize}; -use serde_with::serde_as; -use tauri::AppHandle; +use serde::{de::DeserializeOwned, Serialize}; use url::Url; use crate::DB; -use super::models::data::{Database, GameVersion}; +use super::models::data::Database; pub static DATA_ROOT_DIR: LazyLock> = LazyLock::new(|| Mutex::new(BaseDirs::new().unwrap().data_dir().join("drop"))); diff --git a/src-tauri/src/database/mod.rs b/src-tauri/src/database/mod.rs index aa2973f..edc3061 100644 --- a/src-tauri/src/database/mod.rs +++ b/src-tauri/src/database/mod.rs @@ -1,4 +1,4 @@ pub mod commands; pub mod db; pub mod debug; -pub mod models; \ No newline at end of file +pub mod models; diff --git a/src-tauri/src/database/models.rs b/src-tauri/src/database/models.rs index 48f79b3..fd17c8a 100644 --- a/src-tauri/src/database/models.rs +++ b/src-tauri/src/database/models.rs @@ -162,7 +162,7 @@ pub mod data { } pub mod v2 { - use std::{collections::HashMap, io::ErrorKind, path::PathBuf, process::Command}; + use std::{collections::HashMap, path::PathBuf, process::Command}; use crate::process::process_manager::UMU_LAUNCHER_EXECUTABLE; diff --git a/src-tauri/src/download_manager/download_manager.rs b/src-tauri/src/download_manager/download_manager.rs index 86678de..9b7d209 100644 --- a/src-tauri/src/download_manager/download_manager.rs +++ b/src-tauri/src/download_manager/download_manager.rs @@ -12,11 +12,13 @@ use std::{ use log::{debug, info}; use serde::Serialize; -use crate::{database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError}; +use crate::{ + database::models::data::DownloadableMetadata, + error::application_download_error::ApplicationDownloadError, +}; use super::{ - download_manager_builder::{CurrentProgressObject, DownloadAgent}, - queue::Queue, + download_manager_builder::{CurrentProgressObject, DownloadAgent}, util::queue::Queue, }; pub enum DownloadManagerSignal { diff --git a/src-tauri/src/download_manager/download_manager_builder.rs b/src-tauri/src/download_manager/download_manager_builder.rs index 6359b36..0398eb6 100644 --- a/src-tauri/src/download_manager/download_manager_builder.rs +++ b/src-tauri/src/download_manager/download_manager_builder.rs @@ -11,15 +11,14 @@ use log::{debug, error, info, warn}; use tauri::{AppHandle, Emitter}; use crate::{ - database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError, games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent} + database::models::data::DownloadableMetadata, + error::application_download_error::ApplicationDownloadError, + games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent}, }; use super::{ download_manager::{DownloadManager, DownloadManagerSignal, DownloadManagerStatus}, - download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag}, - downloadable::Downloadable, - progress_object::ProgressObject, - queue::Queue, + downloadable::Downloadable, util::{download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag}, progress_object::ProgressObject, queue::Queue}, }; pub type DownloadAgent = Arc>; diff --git a/src-tauri/src/download_manager/downloadable.rs b/src-tauri/src/download_manager/downloadable.rs index 00743a2..be88e52 100644 --- a/src-tauri/src/download_manager/downloadable.rs +++ b/src-tauri/src/download_manager/downloadable.rs @@ -2,11 +2,13 @@ use std::sync::Arc; use tauri::AppHandle; -use crate::{database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError}; +use crate::{ + database::models::data::DownloadableMetadata, + error::application_download_error::ApplicationDownloadError, +}; use super::{ - download_manager::DownloadStatus, download_thread_control_flag::DownloadThreadControl, - progress_object::ProgressObject, + download_manager::DownloadStatus, util::{download_thread_control_flag::DownloadThreadControl, progress_object::ProgressObject}, }; pub trait Downloadable: Send + Sync { diff --git a/src-tauri/src/download_manager/internal_error.rs b/src-tauri/src/download_manager/internal_error.rs deleted file mode 100644 index 4864599..0000000 --- a/src-tauri/src/download_manager/internal_error.rs +++ /dev/null @@ -1,27 +0,0 @@ -use std::{fmt::Display, io, sync::mpsc::SendError}; - -use serde_with::SerializeDisplay; - -#[derive(SerializeDisplay)] -pub enum InternalError { - IOError(io::Error), - SignalError(SendError), -} -impl Display for InternalError { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self { - InternalError::IOError(error) => write!(f, "{}", error), - InternalError::SignalError(send_error) => write!(f, "{}", send_error), - } - } -} -impl From> for InternalError { - fn from(value: SendError) -> Self { - InternalError::SignalError(value) - } -} -impl From for InternalError { - fn from(value: io::Error) -> Self { - InternalError::IOError(value) - } -} diff --git a/src-tauri/src/download_manager/mod.rs b/src-tauri/src/download_manager/mod.rs index 9aa4db9..c7ae9d0 100644 --- a/src-tauri/src/download_manager/mod.rs +++ b/src-tauri/src/download_manager/mod.rs @@ -1,9 +1,5 @@ pub mod commands; pub mod download_manager; pub mod download_manager_builder; -pub mod download_thread_control_flag; pub mod downloadable; -pub mod internal_error; -pub mod progress_object; -pub mod queue; -pub mod rolling_progress_updates; +pub mod util; \ No newline at end of file diff --git a/src-tauri/src/download_manager/download_thread_control_flag.rs b/src-tauri/src/download_manager/util/download_thread_control_flag.rs similarity index 100% rename from src-tauri/src/download_manager/download_thread_control_flag.rs rename to src-tauri/src/download_manager/util/download_thread_control_flag.rs diff --git a/src-tauri/src/download_manager/util/mod.rs b/src-tauri/src/download_manager/util/mod.rs new file mode 100644 index 0000000..9463f1e --- /dev/null +++ b/src-tauri/src/download_manager/util/mod.rs @@ -0,0 +1,4 @@ +pub mod progress_object; +pub mod queue; +pub mod rolling_progress_updates; +pub mod download_thread_control_flag; \ No newline at end of file diff --git a/src-tauri/src/download_manager/progress_object.rs b/src-tauri/src/download_manager/util/progress_object.rs similarity index 97% rename from src-tauri/src/download_manager/progress_object.rs rename to src-tauri/src/download_manager/util/progress_object.rs index fc0907b..22c44aa 100644 --- a/src-tauri/src/download_manager/progress_object.rs +++ b/src-tauri/src/download_manager/util/progress_object.rs @@ -10,8 +10,10 @@ use std::{ use atomic_instant_full::AtomicInstant; use throttle_my_fn::throttle; +use crate::download_manager::download_manager::DownloadManagerSignal; + use super::{ - download_manager::DownloadManagerSignal, rolling_progress_updates::RollingProgressWindow, + rolling_progress_updates::RollingProgressWindow, }; #[derive(Clone)] diff --git a/src-tauri/src/download_manager/queue.rs b/src-tauri/src/download_manager/util/queue.rs similarity index 100% rename from src-tauri/src/download_manager/queue.rs rename to src-tauri/src/download_manager/util/queue.rs diff --git a/src-tauri/src/download_manager/rolling_progress_updates.rs b/src-tauri/src/download_manager/util/rolling_progress_updates.rs similarity index 100% rename from src-tauri/src/download_manager/rolling_progress_updates.rs rename to src-tauri/src/download_manager/util/rolling_progress_updates.rs diff --git a/src-tauri/src/error/download_manager_error.rs b/src-tauri/src/error/download_manager_error.rs new file mode 100644 index 0000000..29c1fea --- /dev/null +++ b/src-tauri/src/error/download_manager_error.rs @@ -0,0 +1,27 @@ +use std::{fmt::Display, io, sync::mpsc::SendError}; + +use serde_with::SerializeDisplay; + +#[derive(SerializeDisplay)] +pub enum DownloadManagerError { + IOError(io::Error), + SignalError(SendError), +} +impl Display for DownloadManagerError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + DownloadManagerError::IOError(error) => write!(f, "{}", error), + DownloadManagerError::SignalError(send_error) => write!(f, "{}", send_error), + } + } +} +impl From> for DownloadManagerError { + fn from(value: SendError) -> Self { + DownloadManagerError::SignalError(value) + } +} +impl From for DownloadManagerError { + fn from(value: io::Error) -> Self { + DownloadManagerError::IOError(value) + } +} diff --git a/src-tauri/src/error/mod.rs b/src-tauri/src/error/mod.rs index 89b74ae..6800740 100644 --- a/src-tauri/src/error/mod.rs +++ b/src-tauri/src/error/mod.rs @@ -1,5 +1,6 @@ pub mod application_download_error; pub mod drop_server_error; +pub mod download_manager_error; pub mod library_error; pub mod process_error; pub mod remote_access_error; diff --git a/src-tauri/src/error/remote_access_error.rs b/src-tauri/src/error/remote_access_error.rs index ff119ad..9f2407f 100644 --- a/src-tauri/src/error/remote_access_error.rs +++ b/src-tauri/src/error/remote_access_error.rs @@ -1,5 +1,4 @@ use std::{ - any::{Any, TypeId}, error::Error, fmt::{Display, Formatter}, sync::Arc, @@ -23,7 +22,6 @@ pub enum RemoteAccessError { ManifestDownloadFailed(StatusCode, String), OutOfSync, Cache(cacache::Error), - Generic(String), } impl Display for RemoteAccessError { @@ -59,7 +57,6 @@ impl Display for RemoteAccessError { status, response ), RemoteAccessError::OutOfSync => write!(f, "server's and client's time are out of sync. Please ensure they are within at least 30 seconds of each other"), - RemoteAccessError::Generic(message) => write!(f, "{}", message), RemoteAccessError::Cache(error) => write!(f, "Cache Error: {}", error), } } diff --git a/src-tauri/src/games/collections/collection.rs b/src-tauri/src/games/collections/collection.rs index 673c0d6..05fd842 100644 --- a/src-tauri/src/games/collections/collection.rs +++ b/src-tauri/src/games/collections/collection.rs @@ -11,7 +11,7 @@ pub struct Collection { name: String, is_default: bool, user_id: String, - entries: Vec + entries: Vec, } #[derive(Serialize, Deserialize, Debug, Clone, Default)] @@ -21,4 +21,3 @@ pub struct CollectionObject { game_id: String, game: Game, } - diff --git a/src-tauri/src/games/collections/commands.rs b/src-tauri/src/games/collections/commands.rs index 9c202c9..6688d1b 100644 --- a/src-tauri/src/games/collections/commands.rs +++ b/src-tauri/src/games/collections/commands.rs @@ -2,7 +2,12 @@ use reqwest::blocking::Client; use serde_json::json; use url::Url; -use crate::{database::db::DatabaseImpls, error::remote_access_error::RemoteAccessError, remote::{auth::generate_authorization_header, requests::make_request}, DB}; +use crate::{ + database::db::DatabaseImpls, + error::remote_access_error::RemoteAccessError, + remote::{auth::generate_authorization_header, requests::make_request}, + DB, +}; use super::collection::{Collection, Collections}; @@ -20,9 +25,12 @@ pub fn fetch_collections() -> Result { #[tauri::command] pub fn fetch_collection(collection_id: String) -> Result { let client = Client::new(); - let response = make_request(&client, &["/api/v1/client/collection/", &collection_id], &[], |r| { - r.header("Authorization", generate_authorization_header()) - })? + let response = make_request( + &client, + &["/api/v1/client/collection/", &collection_id], + &[], + |r| r.header("Authorization", generate_authorization_header()), + )? .send()?; Ok(response.json()?) @@ -35,20 +43,26 @@ pub fn create_collection(name: String) -> Result let base_url = Url::parse(&format!("{}api/v1/client/collection/", base_url))?; - let response = client .post(base_url) .header("Authorization", generate_authorization_header()) .json(&json!({"name": name})) .send()?; - + Ok(response.json()?) } #[tauri::command] -pub fn add_game_to_collection(collection_id: String, game_id: String) -> Result<(), RemoteAccessError> { +pub fn add_game_to_collection( + collection_id: String, + game_id: String, +) -> Result<(), RemoteAccessError> { let client = Client::new(); - let url = Url::parse(&format!("{}api/v1/client/collection/{}/entry/", DB.fetch_base_url(), collection_id))?; + let url = Url::parse(&format!( + "{}api/v1/client/collection/{}/entry/", + DB.fetch_base_url(), + collection_id + ))?; client .post(url) @@ -61,7 +75,11 @@ pub fn add_game_to_collection(collection_id: String, game_id: String) -> Result< #[tauri::command] pub fn delete_collection(collection_id: String) -> Result { let client = Client::new(); - let base_url = Url::parse(&format!("{}api/v1/client/collection/{}", DB.fetch_base_url(), collection_id))?; + let base_url = Url::parse(&format!( + "{}api/v1/client/collection/{}", + DB.fetch_base_url(), + collection_id + ))?; let response = client .delete(base_url) @@ -71,9 +89,16 @@ pub fn delete_collection(collection_id: String) -> Result Result<(), RemoteAccessError> { +pub fn delete_game_in_collection( + collection_id: String, + game_id: String, +) -> Result<(), RemoteAccessError> { let client = Client::new(); - let base_url = Url::parse(&format!("{}api/v1/client/collection/{}/entry", DB.fetch_base_url(), collection_id))?; + let base_url = Url::parse(&format!( + "{}api/v1/client/collection/{}/entry", + DB.fetch_base_url(), + collection_id + ))?; client .delete(base_url) @@ -82,4 +107,4 @@ pub fn delete_game_in_collection(collection_id: String, game_id: String) -> Resu .send()?; Ok(()) -} \ No newline at end of file +} diff --git a/src-tauri/src/games/collections/mod.rs b/src-tauri/src/games/collections/mod.rs index ea3baf6..b837592 100644 --- a/src-tauri/src/games/collections/mod.rs +++ b/src-tauri/src/games/collections/mod.rs @@ -1,2 +1,2 @@ +pub mod collection; pub mod commands; -pub mod collection; \ No newline at end of file diff --git a/src-tauri/src/games/commands.rs b/src-tauri/src/games/commands.rs index 0570410..8a95132 100644 --- a/src-tauri/src/games/commands.rs +++ b/src-tauri/src/games/commands.rs @@ -1,6 +1,6 @@ use std::sync::Mutex; -use tauri::{AppHandle, Manager}; +use tauri::AppHandle; use crate::{ database::models::data::GameVersion, diff --git a/src-tauri/src/games/downloads/commands.rs b/src-tauri/src/games/downloads/commands.rs index 67b1359..76db029 100644 --- a/src-tauri/src/games/downloads/commands.rs +++ b/src-tauri/src/games/downloads/commands.rs @@ -3,9 +3,7 @@ use std::sync::{Arc, Mutex}; use crate::{ download_manager::{ download_manager::DownloadManagerSignal, downloadable::Downloadable, - internal_error::InternalError, - }, - AppState, + }, error::download_manager_error::DownloadManagerError, AppState }; use super::download_agent::GameDownloadAgent; @@ -16,7 +14,7 @@ pub fn download_game( game_version: String, install_dir: usize, state: tauri::State<'_, Mutex>, -) -> Result<(), InternalError> { +) -> Result<(), DownloadManagerError> { let sender = state.lock().unwrap().download_manager.get_sender(); let game_download_agent = Arc::new(Box::new(GameDownloadAgent::new( game_id, diff --git a/src-tauri/src/games/downloads/download_agent.rs b/src-tauri/src/games/downloads/download_agent.rs index 4980d2b..267cd9b 100644 --- a/src-tauri/src/games/downloads/download_agent.rs +++ b/src-tauri/src/games/downloads/download_agent.rs @@ -1,12 +1,12 @@ use crate::auth::generate_authorization_header; use crate::database::db::borrow_db_checked; -use crate::database::models::data::{ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus}; -use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus}; -use crate::download_manager::download_thread_control_flag::{ - DownloadThreadControl, DownloadThreadControlFlag, +use crate::database::models::data::{ + ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus, }; +use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus}; use crate::download_manager::downloadable::Downloadable; -use crate::download_manager::progress_object::{ProgressHandle, ProgressObject}; +use crate::download_manager::util::download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag}; +use crate::download_manager::util::progress_object::{ProgressHandle, ProgressObject}; use crate::error::application_download_error::ApplicationDownloadError; use crate::error::remote_access_error::RemoteAccessError; use crate::games::downloads::manifest::{DropDownloadContext, DropManifest}; diff --git a/src-tauri/src/games/downloads/download_logic.rs b/src-tauri/src/games/downloads/download_logic.rs index 70e5b7e..6ec5ed3 100644 --- a/src-tauri/src/games/downloads/download_logic.rs +++ b/src-tauri/src/games/downloads/download_logic.rs @@ -1,7 +1,5 @@ -use crate::download_manager::download_thread_control_flag::{ - DownloadThreadControl, DownloadThreadControlFlag, -}; -use crate::download_manager::progress_object::ProgressHandle; +use crate::download_manager::util::download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag}; +use crate::download_manager::util::progress_object::ProgressHandle; use crate::error::application_download_error::ApplicationDownloadError; use crate::error::remote_access_error::RemoteAccessError; use crate::games::downloads::manifest::DropDownloadContext; diff --git a/src-tauri/src/games/library.rs b/src-tauri/src/games/library.rs index daa011d..d62238a 100644 --- a/src-tauri/src/games/library.rs +++ b/src-tauri/src/games/library.rs @@ -2,13 +2,15 @@ use std::fs::remove_dir_all; use std::sync::Mutex; use std::thread::spawn; -use log::{debug, error, info, warn}; +use log::{debug, error, warn}; use serde::{Deserialize, Serialize}; use tauri::Emitter; -use tauri::{AppHandle, Manager}; +use tauri::AppHandle; use crate::database::db::{borrow_db_checked, borrow_db_mut_checked, save_db}; -use crate::database::models::data::{ApplicationTransientStatus, DownloadableMetadata, GameDownloadStatus, GameVersion}; +use crate::database::models::data::{ + ApplicationTransientStatus, DownloadableMetadata, GameDownloadStatus, GameVersion, +}; use crate::download_manager::download_manager::DownloadStatus; use crate::error::library_error::LibraryError; use crate::error::remote_access_error::RemoteAccessError; diff --git a/src-tauri/src/games/mod.rs b/src-tauri/src/games/mod.rs index 8b13190..0d81d10 100644 --- a/src-tauri/src/games/mod.rs +++ b/src-tauri/src/games/mod.rs @@ -1,5 +1,5 @@ +pub mod collections; pub mod commands; pub mod downloads; pub mod library; pub mod state; -pub mod collections; \ No newline at end of file diff --git a/src-tauri/src/games/state.rs b/src-tauri/src/games/state.rs index b574daa..c95c0d5 100644 --- a/src-tauri/src/games/state.rs +++ b/src-tauri/src/games/state.rs @@ -1,4 +1,7 @@ -use crate::database::{db::borrow_db_checked, models::data::{ApplicationTransientStatus, GameDownloadStatus}}; +use crate::database::{ + db::borrow_db_checked, + models::data::{ApplicationTransientStatus, GameDownloadStatus}, +}; pub type GameStatusWithTransient = ( Option, diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 67d2582..99e6278 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,18 +1,18 @@ mod database; mod games; -mod autostart; -mod cleanup; -mod commands; +mod client; mod download_manager; mod error; mod process; mod remote; use crate::database::db::DatabaseImpls; -use autostart::{get_autostart_enabled, toggle_autostart}; -use cleanup::{cleanup_and_exit, quit}; -use commands::fetch_state; +use client::{ + autostart::{get_autostart_enabled, sync_autostart_on_startup, toggle_autostart}, + cleanup::{cleanup_and_exit, quit}, +}; +use client::commands::fetch_state; use database::commands::{ add_download_dir, delete_download_dir, fetch_download_dir_stats, fetch_settings, fetch_system_data, update_settings, @@ -33,7 +33,6 @@ use games::commands::{ }; use games::downloads::commands::download_game; use games::library::{update_game_configuration, Game}; -use http::Response; use log::{debug, info, warn, LevelFilter}; use log4rs::append::console::ConsoleAppender; use log4rs::append::file::FileAppender; @@ -48,9 +47,7 @@ use remote::commands::{ sign_out, use_remote, }; use remote::fetch_object::{fetch_object, fetch_object_offline}; -use remote::requests::make_request; use remote::server_proto::{handle_server_proto, handle_server_proto_offline}; -use reqwest::blocking::Body; use serde::{Deserialize, Serialize}; use std::env; use std::path::Path; @@ -196,7 +193,7 @@ fn setup(handle: AppHandle) -> AppState<'static> { debug!("finished setup!"); // Sync autostart state - if let Err(e) = autostart::sync_autostart_on_startup(&handle) { + if let Err(e) = sync_autostart_on_startup(&handle) { warn!("failed to sync autostart state: {}", e); } diff --git a/src-tauri/src/process/compat.rs b/src-tauri/src/process/compat.rs index e69de29..8b13789 100644 --- a/src-tauri/src/process/compat.rs +++ b/src-tauri/src/process/compat.rs @@ -0,0 +1 @@ + diff --git a/src-tauri/src/process/process_manager.rs b/src-tauri/src/process/process_manager.rs index de98ee6..ba0cf08 100644 --- a/src-tauri/src/process/process_manager.rs +++ b/src-tauri/src/process/process_manager.rs @@ -1,9 +1,9 @@ use std::{ collections::HashMap, - fs::{File, OpenOptions}, - io::{self, Error}, - path::{Path, PathBuf}, - process::{Child, Command, ExitStatus}, + fs::OpenOptions, + io::{self}, + path::PathBuf, + process::{Command, ExitStatus}, str::FromStr, sync::{Arc, Mutex}, thread::spawn, @@ -15,12 +15,14 @@ use log::{debug, info, warn}; use serde::{Deserialize, Serialize}; use shared_child::SharedChild; use tauri::{AppHandle, Manager}; -use umu_wrapper_lib::command_builder::UmuCommandBuilder; use crate::{ database::{ db::{borrow_db_mut_checked, DATA_ROOT_DIR}, - models::data::{ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus, GameVersion}, + models::data::{ + ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus, + GameVersion, + }, }, error::process_error::ProcessError, games::{library::push_game_update, state::GameStatusManager}, @@ -46,7 +48,7 @@ impl ProcessManager<'_> { current_platform: Platform::Windows, #[cfg(target_os = "macos")] - current_platform: Platform::macOS, + current_platform: Platform::MacOs, #[cfg(target_os = "linux")] current_platform: Platform::Linux, @@ -65,7 +67,7 @@ impl ProcessManager<'_> { &NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static), ), ( - (Platform::macOS, Platform::macOS), + (Platform::MacOs, Platform::MacOs), &NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static), ), ( @@ -330,7 +332,7 @@ impl ProcessManager<'_> { pub enum Platform { Windows, Linux, - macOS, + MacOs, } pub trait ProcessHandler: Send + 'static { @@ -351,8 +353,8 @@ impl ProcessHandler for NativeGameLauncher { _meta: &DownloadableMetadata, launch_command: String, args: Vec, - game_version: &GameVersion, - current_dir: &str, + _game_version: &GameVersion, + _current_dir: &str, ) -> String { format!("\"{}\" {}", launch_command, args.join(" ")) } diff --git a/src-tauri/src/remote/auth.rs b/src-tauri/src/remote/auth.rs index d7a7036..346a224 100644 --- a/src-tauri/src/remote/auth.rs +++ b/src-tauri/src/remote/auth.rs @@ -1,21 +1,20 @@ -use std::{collections::HashMap, env, sync::Mutex}; +use std::{collections::HashMap, env}; use chrono::Utc; use droplet_rs::ssl::sign_nonce; use gethostname::gethostname; use log::{debug, error, warn}; use serde::{Deserialize, Serialize}; -use serde_json::json; -use tauri::{AppHandle, Emitter, Manager}; +use tauri::{AppHandle, Emitter}; use url::Url; use crate::{ database::{ - db::{borrow_db_checked, borrow_db_mut_checked, save_db, DatabaseImpls}, + db::{borrow_db_checked, borrow_db_mut_checked, save_db}, models::data::DatabaseAuth, }, error::{drop_server_error::DropServerError, remote_access_error::RemoteAccessError}, - AppState, AppStatus, User, DB, + AppStatus, User, }; use super::{ diff --git a/src-tauri/src/remote/cache.rs b/src-tauri/src/remote/cache.rs index f5c5762..062fe75 100644 --- a/src-tauri/src/remote/cache.rs +++ b/src-tauri/src/remote/cache.rs @@ -1,6 +1,7 @@ -use std::sync::RwLockReadGuard; - -use crate::{database::{db::borrow_db_checked, models::data::Database}, error::remote_access_error::RemoteAccessError}; +use crate::{ + database::{db::borrow_db_checked, models::data::Database}, + error::remote_access_error::RemoteAccessError, +}; use cacache::Integrity; use http::{header::CONTENT_TYPE, response::Builder as ResponseBuilder, Response}; use serde::{de::DeserializeOwned, Deserialize, Serialize}; diff --git a/src-tauri/src/remote/commands.rs b/src-tauri/src/remote/commands.rs index 270b800..37039e6 100644 --- a/src-tauri/src/remote/commands.rs +++ b/src-tauri/src/remote/commands.rs @@ -6,11 +6,16 @@ use tauri::{AppHandle, Emitter, Manager}; use url::Url; use crate::{ - database::db::{borrow_db_checked, borrow_db_mut_checked, save_db}, error::remote_access_error::RemoteAccessError, remote::{auth::generate_authorization_header, requests::make_request}, AppState, AppStatus + database::db::{borrow_db_checked, borrow_db_mut_checked, save_db}, + error::remote_access_error::RemoteAccessError, + remote::{auth::generate_authorization_header, requests::make_request}, + AppState, AppStatus, }; use super::{ - auth::{auth_initiate_logic, recieve_handshake, setup}, cache::{cache_object, get_cached_object}, remote::use_remote_logic + auth::{auth_initiate_logic, recieve_handshake, setup}, + cache::{cache_object, get_cached_object}, + remote::use_remote_logic, }; #[tauri::command] @@ -36,24 +41,22 @@ pub fn gen_drop_url(path: String) -> Result { #[tauri::command] pub fn fetch_drop_object(path: String) -> Result, RemoteAccessError> { - let drop_url = gen_drop_url(path.clone()); - let req = make_request( - &Client::new(), - &[&path], - &[], - |r| { r.header("Authorization", generate_authorization_header()) } - )?.send(); + let _drop_url = gen_drop_url(path.clone())?; + let req = make_request(&Client::new(), &[&path], &[], |r| { + r.header("Authorization", generate_authorization_header()) + })? + .send(); match req { Ok(data) => { let data = data.bytes()?.to_vec(); cache_object(&path, &data)?; Ok(data) - }, + } Err(e) => { debug!("{}", e); get_cached_object::<&str, Vec>(&path) - }, + } } } #[tauri::command] diff --git a/src-tauri/src/remote/fetch_object.rs b/src-tauri/src/remote/fetch_object.rs index 8702b93..4900b6d 100644 --- a/src-tauri/src/remote/fetch_object.rs +++ b/src-tauri/src/remote/fetch_object.rs @@ -2,12 +2,13 @@ use http::{header::CONTENT_TYPE, response::Builder as ResponseBuilder}; use log::warn; use tauri::UriSchemeResponder; -use super::{auth::generate_authorization_header, cache::{cache_object, get_cached_object, ObjectCache}, requests::make_request}; +use super::{ + auth::generate_authorization_header, + cache::{cache_object, get_cached_object, ObjectCache}, + requests::make_request, +}; -pub fn fetch_object( - request: http::Request>, - responder: UriSchemeResponder, -) { +pub fn fetch_object(request: http::Request>, responder: UriSchemeResponder) { // Drop leading / let object_id = &request.uri().path()[1..]; @@ -25,7 +26,7 @@ pub fn fetch_object( Ok(data) => responder.respond(data.into()), Err(e) => { warn!("{}", e) - }, + } } return; } @@ -41,10 +42,7 @@ pub fn fetch_object( responder.respond(resp); } -pub fn fetch_object_offline( - request: http::Request>, - responder: UriSchemeResponder, -) { +pub fn fetch_object_offline(request: http::Request>, responder: UriSchemeResponder) { let object_id = &request.uri().path()[1..]; let data = get_cached_object::<&str, ObjectCache>(object_id); diff --git a/src-tauri/src/remote/mod.rs b/src-tauri/src/remote/mod.rs index 5c71b24..3352f0e 100644 --- a/src-tauri/src/remote/mod.rs +++ b/src-tauri/src/remote/mod.rs @@ -5,4 +5,4 @@ pub mod commands; pub mod fetch_object; pub mod remote; pub mod requests; -pub mod server_proto; \ No newline at end of file +pub mod server_proto; diff --git a/src-tauri/src/remote/server_proto.rs b/src-tauri/src/remote/server_proto.rs index 920778e..00c215b 100644 --- a/src-tauri/src/remote/server_proto.rs +++ b/src-tauri/src/remote/server_proto.rs @@ -1,10 +1,9 @@ -use std::{path::PathBuf, str::FromStr}; +use std::str::FromStr; use http::{ - uri::{Authority, PathAndQuery}, + uri::PathAndQuery, Request, Response, StatusCode, Uri, }; -use log::info; use reqwest::blocking::Client; use tauri::UriSchemeResponder; diff --git a/src-tauri/tailscale/src/bindings.rs b/src-tauri/tailscale/src/bindings.rs index 916280a..21a84f0 100644 --- a/src-tauri/tailscale/src/bindings.rs +++ b/src-tauri/tailscale/src/bindings.rs @@ -1,5 +1,4 @@ /* automatically generated by rust-bindgen 0.71.1 */ - #[derive(PartialEq, Copy, Clone, Hash, Debug, Default)] #[repr(C)] pub struct __BindgenComplex {