refactor(download manager): Moved manifest and stored_manifest to download_manager

Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
quexeky
2024-12-31 12:53:31 +11:00
parent 4c37ab03ed
commit ece79e4306
10 changed files with 46 additions and 37 deletions
@@ -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<PathBuf>;
}
-1
View File
@@ -1,4 +1,3 @@
mod external_component;
mod prefix;
mod registry;
mod tool;
+3 -2
View File
@@ -1,7 +1,8 @@
use std::collections::HashMap;
use super::external_component::ExternalComponent;
use crate::download_manager::downloadable::Downloadable;
pub struct Registry<T: ExternalComponent> {
pub struct Registry<T: Downloadable> {
tools: HashMap<String, T>
}
+28 -12
View File
@@ -1,26 +1,42 @@
use std::path::PathBuf;
use std::{path::PathBuf, sync::Arc};
use super::external_component::ExternalComponent;
use rustix::path::Arg;
pub struct Tool {
name: String,
use crate::download_manager::{download_thread_control_flag::DownloadThreadControl, downloadable::Downloadable, progress_object::ProgressObject};
pub struct ToolDownloader {
id: String,
version: String,
location: Option<PathBuf>,
progress: Arc<ProgressObject>,
control_flag: DownloadThreadControl
}
impl ExternalComponent for Tool {
fn download(&mut self) {
impl Downloadable for ToolDownloader {
fn get_progress_object(&self) -> std::sync::Arc<crate::download_manager::progress_object::ProgressObject> {
todo!()
}
fn version(&self) -> &String {
&self.version
fn version(&self) -> String {
self.version.clone()
}
fn is_installed(&self) -> bool {
self.location.is_some()
fn id(&self) -> String {
self.id.clone()
}
fn location(&self) -> &Option<PathBuf> {
&self.location
fn download(&mut self) -> Result<(), crate::download_manager::application_download_error::ApplicationDownloadError> {
todo!()
}
fn progress(&self) -> Arc<ProgressObject> {
self.progress.clone()
}
fn control_flag(&self) -> DownloadThreadControl {
self.control_flag.clone()
}
fn install_dir(&self) -> String {
self.location.clone().unwrap().to_string_lossy().to_string()
}
}