From e147088375160721b5ca17038ad898becb2a5952 Mon Sep 17 00:00:00 2001 From: quexeky Date: Tue, 31 Dec 2024 13:18:00 +1100 Subject: [PATCH] chore(tool manager): Added ToolDownloadAgent Signed-off-by: quexeky --- .../src/download_manager/downloadable.rs | 1 - .../src-tauri/src/downloads/download_agent.rs | 4 -- .../src-tauri/src/tools/external_component.rs | 8 ---- desktop/src-tauri/src/tools/mod.rs | 1 - desktop/src-tauri/src/tools/registry.rs | 4 +- desktop/src-tauri/src/tools/tool.rs | 48 +++++++++++-------- 6 files changed, 31 insertions(+), 35 deletions(-) delete mode 100644 desktop/src-tauri/src/tools/external_component.rs diff --git a/desktop/src-tauri/src/download_manager/downloadable.rs b/desktop/src-tauri/src/download_manager/downloadable.rs index cb09d9ee..01c5df39 100644 --- a/desktop/src-tauri/src/download_manager/downloadable.rs +++ b/desktop/src-tauri/src/download_manager/downloadable.rs @@ -5,7 +5,6 @@ use super::{ }; pub trait Downloadable: Send + Sync { - fn get_progress_object(&self) -> Arc; fn version(&self) -> String; fn id(&self) -> String; fn download(&mut self) -> Result<(), ApplicationDownloadError>; diff --git a/desktop/src-tauri/src/downloads/download_agent.rs b/desktop/src-tauri/src/downloads/download_agent.rs index df0b3cac..dcfa6930 100644 --- a/desktop/src-tauri/src/downloads/download_agent.rs +++ b/desktop/src-tauri/src/downloads/download_agent.rs @@ -296,10 +296,6 @@ impl GameDownloadAgent { } impl Downloadable for GameDownloadAgent { - fn get_progress_object(&self) -> Arc { - self.progress.clone() - } - fn id(&self) -> String { self.id.clone() } diff --git a/desktop/src-tauri/src/tools/external_component.rs b/desktop/src-tauri/src/tools/external_component.rs deleted file mode 100644 index 2aec4b7c..00000000 --- a/desktop/src-tauri/src/tools/external_component.rs +++ /dev/null @@ -1,8 +0,0 @@ -use std::path::PathBuf; - -pub trait ExternalComponent { - fn download(&mut self); - fn version(&self) -> &String; - fn is_installed(&self) -> bool; - fn location(&self) -> &Option; -} \ No newline at end of file diff --git a/desktop/src-tauri/src/tools/mod.rs b/desktop/src-tauri/src/tools/mod.rs index 6b8f4133..960f1321 100644 --- a/desktop/src-tauri/src/tools/mod.rs +++ b/desktop/src-tauri/src/tools/mod.rs @@ -1,4 +1,3 @@ -mod external_component; mod prefix; mod registry; mod tool; \ No newline at end of file diff --git a/desktop/src-tauri/src/tools/registry.rs b/desktop/src-tauri/src/tools/registry.rs index c1b000fb..fa50426a 100644 --- a/desktop/src-tauri/src/tools/registry.rs +++ b/desktop/src-tauri/src/tools/registry.rs @@ -1,7 +1,7 @@ use std::collections::HashMap; -use super::external_component::ExternalComponent; +use crate::download_manager::downloadable::Downloadable; -pub struct Registry { +pub struct Registry { tools: HashMap } diff --git a/desktop/src-tauri/src/tools/tool.rs b/desktop/src-tauri/src/tools/tool.rs index 6fab0251..cd75325d 100644 --- a/desktop/src-tauri/src/tools/tool.rs +++ b/desktop/src-tauri/src/tools/tool.rs @@ -1,26 +1,36 @@ -use std::path::PathBuf; +use std::sync::Arc; -use super::external_component::ExternalComponent; +use crate::download_manager::{download_thread_control_flag::DownloadThreadControl, downloadable::Downloadable, progress_object::ProgressObject}; -pub struct Tool { - name: String, +pub struct ToolDownloadAgent { + id: String, version: String, - location: Option, + location: String, + control_flag: DownloadThreadControl, + progress: Arc, } -impl ExternalComponent for Tool { - fn download(&mut self) { +impl Downloadable for ToolDownloadAgent { + fn id(&self) -> String { + self.id.clone() + } + + fn progress(&self) -> Arc { + self.progress.clone() + } + + fn control_flag(&self) -> DownloadThreadControl { + self.control_flag.clone() + } + + fn install_dir(&self) -> String { + self.location.clone() + } + + fn version(&self) -> String { + self.version.clone() + } + + fn download(&mut self) -> Result<(), crate::download_manager::application_download_error::ApplicationDownloadError> { todo!() } - - fn version(&self) -> &String { - &self.version - } - - fn is_installed(&self) -> bool { - self.location.is_some() - } - - fn location(&self) -> &Option { - &self.location - } } \ No newline at end of file