mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 16:22:43 +10:00
chore: More cleanup after cargo clippy
Also added some type efficiency improvements (using references where possible and added SliceDeque crate) Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
21
src-tauri/Cargo.lock
generated
21
src-tauri/Cargo.lock
generated
@ -1020,6 +1020,7 @@ dependencies = [
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
"shared_child",
|
||||
"slice-deque",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-autostart",
|
||||
@ -2359,6 +2360,15 @@ version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
|
||||
|
||||
[[package]]
|
||||
name = "mach"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b823e83b2affd8f40a9ee8c29dbc56404c1e34cd2710921f2801e2cf29527afa"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "malloc_buf"
|
||||
version = "0.0.6"
|
||||
@ -3998,6 +4008,17 @@ dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slice-deque"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "31ef6ee280cdefba6d2d0b4b78a84a1c1a3f3a4cec98c2d4231c8bc225de0f25"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"mach",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.13.2"
|
||||
|
||||
@ -46,6 +46,7 @@ umu-wrapper-lib = "0.1.0"
|
||||
tauri-plugin-autostart = "2.0.0"
|
||||
shared_child = "1.0.1"
|
||||
serde_with = "3.12.0"
|
||||
slice-deque = "0.3.0"
|
||||
|
||||
[dependencies.tauri]
|
||||
version = "2.1.1"
|
||||
|
||||
@ -189,7 +189,7 @@ fn auth_initiate_wrapper() -> Result<(), RemoteAccessError> {
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn auth_initiate<'a>() -> Result<(), String> {
|
||||
pub fn auth_initiate() -> Result<(), String> {
|
||||
let result = auth_initiate_wrapper();
|
||||
if result.is_err() {
|
||||
return Err(result.err().unwrap().to_string());
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
use super::{download_manager_builder::DownloadAgent, downloadable_metadata::DownloadableMetadata};
|
||||
|
||||
pub fn generate_downloadable(meta: DownloadableMetadata) -> DownloadAgent {
|
||||
todo!()
|
||||
}
|
||||
@ -4,6 +4,5 @@ pub mod download_manager_builder;
|
||||
pub mod download_thread_control_flag;
|
||||
pub mod downloadable;
|
||||
pub mod downloadable_metadata;
|
||||
pub mod generate_downloadable;
|
||||
pub mod progress_object;
|
||||
pub mod queue;
|
||||
|
||||
@ -14,7 +14,7 @@ use crate::remote::RemoteAccessError;
|
||||
use crate::DB;
|
||||
use log::{debug, error, info};
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use std::collections::VecDeque;
|
||||
use slice_deque::SliceDeque;
|
||||
use std::fs::{create_dir_all, File};
|
||||
use std::path::Path;
|
||||
use std::sync::mpsc::Sender;
|
||||
@ -34,7 +34,7 @@ pub struct GameDownloadAgent {
|
||||
pub version: String,
|
||||
pub control_flag: DownloadThreadControl,
|
||||
contexts: Mutex<Vec<DropDownloadContext>>,
|
||||
completed_contexts: Mutex<VecDeque<usize>>,
|
||||
completed_contexts: Mutex<SliceDeque<usize>>,
|
||||
pub manifest: Mutex<Option<DropManifest>>,
|
||||
pub progress: Arc<ProgressObject>,
|
||||
sender: Sender<DownloadManagerSignal>,
|
||||
@ -68,7 +68,7 @@ impl GameDownloadAgent {
|
||||
control_flag,
|
||||
manifest: Mutex::new(None),
|
||||
contexts: Mutex::new(Vec::new()),
|
||||
completed_contexts: Mutex::new(VecDeque::new()),
|
||||
completed_contexts: Mutex::new(SliceDeque::new()),
|
||||
progress: Arc::new(ProgressObject::new(0, 0, sender.clone())),
|
||||
sender,
|
||||
stored_manifest,
|
||||
@ -312,7 +312,7 @@ impl GameDownloadAgent {
|
||||
if completed_lock_len != contexts.len() {
|
||||
info!("da for {} exited without completing", self.id.clone());
|
||||
self.stored_manifest
|
||||
.set_completed_contexts(&self.completed_contexts.lock().unwrap().clone().into());
|
||||
.set_completed_contexts(self.completed_contexts.lock().unwrap().as_slice());
|
||||
info!("Setting completed contexts");
|
||||
self.stored_manifest.write();
|
||||
info!("Wrote completed contexts");
|
||||
|
||||
@ -56,19 +56,3 @@ pub fn move_game_in_queue(
|
||||
pub fn cancel_game(state: tauri::State<'_, Mutex<AppState>>, meta: DownloadableMetadata) {
|
||||
state.lock().unwrap().download_manager.cancel(meta)
|
||||
}
|
||||
|
||||
/*
|
||||
#[tauri::command]
|
||||
pub fn get_current_write_speed(state: tauri::State<'_, Mutex<AppState>>) {}
|
||||
*/
|
||||
|
||||
/*
|
||||
fn use_download_agent(
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
game_id: String,
|
||||
) -> Result<Arc<GameDownloadAgent>, String> {
|
||||
let lock = state.lock().unwrap();
|
||||
let download_agent = lock.download_manager.get(&game_id).ok_or("Invalid game ID")?;
|
||||
Ok(download_agent.clone()) // Clones the Arc, not the underlying data structure
|
||||
}
|
||||
*/
|
||||
|
||||
@ -70,8 +70,8 @@ impl StoredManifest {
|
||||
Err(e) => error!("{}", e),
|
||||
};
|
||||
}
|
||||
pub fn set_completed_contexts(&self, completed_contexts: &Vec<usize>) {
|
||||
*self.completed_contexts.lock().unwrap() = completed_contexts.clone();
|
||||
pub fn set_completed_contexts(&self, completed_contexts: &[usize]) {
|
||||
*self.completed_contexts.lock().unwrap() = completed_contexts.to_owned();
|
||||
}
|
||||
pub fn get_completed_contexts(&self) -> Vec<usize> {
|
||||
self.completed_contexts.lock().unwrap().clone()
|
||||
|
||||
@ -200,7 +200,7 @@ pub fn fetch_game_status(id: String) -> Result<GameStatusWithTransient, String>
|
||||
Ok(status)
|
||||
}
|
||||
|
||||
fn fetch_game_verion_options_logic<'a>(
|
||||
fn fetch_game_verion_options_logic(
|
||||
game_id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<Vec<GameVersionOption>, RemoteAccessError> {
|
||||
@ -239,7 +239,6 @@ fn fetch_game_verion_options_logic<'a>(
|
||||
#[tauri::command]
|
||||
pub fn uninstall_game(
|
||||
game_id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
app_handle: AppHandle,
|
||||
) -> Result<(), String> {
|
||||
let meta = get_current_meta(&game_id)?;
|
||||
@ -270,7 +269,7 @@ fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle) {
|
||||
return;
|
||||
}
|
||||
let previous_state = previous_state.unwrap();
|
||||
if let Some((version_name, install_dir)) = match previous_state {
|
||||
if let Some((_, install_dir)) = match previous_state {
|
||||
GameDownloadStatus::Installed {
|
||||
version_name,
|
||||
install_dir,
|
||||
@ -330,7 +329,7 @@ pub fn get_current_meta(game_id: &String) -> Result<DownloadableMetadata, String
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn fetch_game_verion_options<'a>(
|
||||
pub fn fetch_game_verion_options(
|
||||
game_id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<Vec<GameVersionOption>, String> {
|
||||
|
||||
@ -402,7 +402,7 @@ pub fn run() {
|
||||
.build(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
|
||||
app.run(|app_handle, event| {
|
||||
app.run(|_app_handle, event| {
|
||||
if let RunEvent::ExitRequested { code, api, .. } = event {
|
||||
if code.is_none() {
|
||||
api.prevent_exit();
|
||||
|
||||
@ -22,11 +22,10 @@ pub fn launch_game(id: String, state: tauri::State<'_, Mutex<AppState>>) -> Resu
|
||||
{
|
||||
Some(GameDownloadStatus::Installed {
|
||||
version_name,
|
||||
install_dir,
|
||||
..
|
||||
}) => version_name,
|
||||
Some(GameDownloadStatus::SetupRequired {
|
||||
version_name,
|
||||
install_dir,
|
||||
..
|
||||
}) => return Err(String::from("Game setup still required")),
|
||||
_ => return Err(String::from("Game not installed")),
|
||||
};
|
||||
|
||||
@ -255,7 +255,7 @@ impl ProcessManager<'_> {
|
||||
&meta,
|
||||
command.to_str().unwrap().to_owned(),
|
||||
args,
|
||||
&target_current_dir.to_string(),
|
||||
target_current_dir,
|
||||
log_file,
|
||||
error_file,
|
||||
)?;
|
||||
@ -313,7 +313,7 @@ pub trait ProcessHandler: Send + 'static {
|
||||
meta: &DownloadableMetadata,
|
||||
command: String,
|
||||
args: Vec<String>,
|
||||
current_dir: &String,
|
||||
current_dir: &str,
|
||||
log_file: File,
|
||||
error_file: File,
|
||||
) -> Result<Child, String>;
|
||||
@ -323,10 +323,10 @@ struct NativeGameLauncher;
|
||||
impl ProcessHandler for NativeGameLauncher {
|
||||
fn launch_process(
|
||||
&self,
|
||||
meta: &DownloadableMetadata,
|
||||
_meta: &DownloadableMetadata,
|
||||
command: String,
|
||||
args: Vec<String>,
|
||||
current_dir: &String,
|
||||
current_dir: &str,
|
||||
log_file: File,
|
||||
error_file: File,
|
||||
) -> Result<Child, String> {
|
||||
@ -345,12 +345,12 @@ struct UMULauncher;
|
||||
impl ProcessHandler for UMULauncher {
|
||||
fn launch_process(
|
||||
&self,
|
||||
meta: &DownloadableMetadata,
|
||||
_meta: &DownloadableMetadata,
|
||||
command: String,
|
||||
args: Vec<String>,
|
||||
current_dir: &String,
|
||||
log_file: File,
|
||||
error_file: File,
|
||||
_current_dir: &str,
|
||||
_log_file: File,
|
||||
_error_file: File,
|
||||
) -> Result<Child, String> {
|
||||
UmuCommandBuilder::new(UMU_LAUNCHER_EXECUTABLE, command)
|
||||
.game_id(String::from("0"))
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
mod compatibility_layer;
|
||||
mod prefix;
|
||||
mod registry;
|
||||
mod tool;
|
||||
|
||||
@ -1,7 +0,0 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::download_manager::downloadable::Downloadable;
|
||||
|
||||
pub struct Registry<T: Downloadable> {
|
||||
tools: HashMap<String, T>,
|
||||
}
|
||||
@ -8,6 +8,7 @@ use crate::download_manager::{
|
||||
downloadable_metadata::DownloadableMetadata, progress_object::ProgressObject,
|
||||
};
|
||||
|
||||
#[allow(unused)]
|
||||
pub struct ToolDownloadAgent {
|
||||
id: String,
|
||||
version: String,
|
||||
@ -15,6 +16,7 @@ pub struct ToolDownloadAgent {
|
||||
control_flag: DownloadThreadControl,
|
||||
progress: Arc<ProgressObject>,
|
||||
}
|
||||
#[allow(unused)]
|
||||
impl Downloadable for ToolDownloadAgent {
|
||||
fn download(&self, app_handle: &AppHandle) -> Result<bool, ApplicationDownloadError> {
|
||||
todo!()
|
||||
|
||||
Reference in New Issue
Block a user