mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-14 16:51:18 +10:00
refactor(download manager): Moved manifest and stored_manifest to download_manager
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@ -3,7 +3,6 @@ use crate::db::DatabaseImpls;
|
|||||||
use crate::download_manager::application_download_error::ApplicationDownloadError;
|
use crate::download_manager::application_download_error::ApplicationDownloadError;
|
||||||
use crate::download_manager::download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag};
|
use crate::download_manager::download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag};
|
||||||
use crate::download_manager::progress_object::ProgressHandle;
|
use crate::download_manager::progress_object::ProgressHandle;
|
||||||
use crate::downloads::manifest::DropDownloadContext;
|
|
||||||
use crate::remote::RemoteAccessError;
|
use crate::remote::RemoteAccessError;
|
||||||
use crate::DB;
|
use crate::DB;
|
||||||
use http::StatusCode;
|
use http::StatusCode;
|
||||||
@ -22,6 +21,8 @@ use std::{
|
|||||||
};
|
};
|
||||||
use urlencoding::encode;
|
use urlencoding::encode;
|
||||||
|
|
||||||
|
use super::manifest::DropDownloadContext;
|
||||||
|
|
||||||
pub struct DropWriter<W: Write> {
|
pub struct DropWriter<W: Write> {
|
||||||
hasher: Context,
|
hasher: Context,
|
||||||
destination: W,
|
destination: W,
|
||||||
@ -5,3 +5,6 @@ pub mod queue;
|
|||||||
pub mod download_thread_control_flag;
|
pub mod download_thread_control_flag;
|
||||||
pub mod downloadable;
|
pub mod downloadable;
|
||||||
pub mod application_download_error;
|
pub mod application_download_error;
|
||||||
|
pub mod download_logic;
|
||||||
|
pub mod manifest;
|
||||||
|
pub mod stored_manifest;
|
||||||
@ -1,11 +1,13 @@
|
|||||||
use crate::auth::generate_authorization_header;
|
use crate::auth::generate_authorization_header;
|
||||||
use crate::db::DatabaseImpls;
|
use crate::db::DatabaseImpls;
|
||||||
use crate::download_manager::application_download_error::ApplicationDownloadError;
|
use crate::download_manager::application_download_error::ApplicationDownloadError;
|
||||||
|
use crate::download_manager::download_logic::download_game_chunk;
|
||||||
use crate::download_manager::download_manager::DownloadManagerSignal;
|
use crate::download_manager::download_manager::DownloadManagerSignal;
|
||||||
use crate::download_manager::download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag};
|
use crate::download_manager::download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag};
|
||||||
use crate::download_manager::downloadable::Downloadable;
|
use crate::download_manager::downloadable::Downloadable;
|
||||||
|
use crate::download_manager::manifest::{DropDownloadContext, DropManifest};
|
||||||
use crate::download_manager::progress_object::{ProgressHandle, ProgressObject};
|
use crate::download_manager::progress_object::{ProgressHandle, ProgressObject};
|
||||||
use crate::downloads::manifest::{DropDownloadContext, DropManifest};
|
use crate::download_manager::stored_manifest::StoredManifest;
|
||||||
use crate::remote::RemoteAccessError;
|
use crate::remote::RemoteAccessError;
|
||||||
use crate::DB;
|
use crate::DB;
|
||||||
use log::{debug, error, info};
|
use log::{debug, error, info};
|
||||||
@ -21,19 +23,17 @@ use urlencoding::encode;
|
|||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use rustix::fs::{fallocate, FallocateFlags};
|
use rustix::fs::{fallocate, FallocateFlags};
|
||||||
|
|
||||||
use super::download_logic::download_game_chunk;
|
|
||||||
use super::stored_manifest::StoredManifest;
|
|
||||||
|
|
||||||
pub struct GameDownloadAgent {
|
pub struct GameDownloadAgent {
|
||||||
pub id: String,
|
id: String,
|
||||||
pub version: String,
|
version: String,
|
||||||
pub control_flag: DownloadThreadControl,
|
control_flag: DownloadThreadControl,
|
||||||
contexts: Vec<DropDownloadContext>,
|
contexts: Vec<DropDownloadContext>,
|
||||||
completed_contexts: VecDeque<usize>,
|
completed_contexts: VecDeque<usize>,
|
||||||
pub manifest: Mutex<Option<DropManifest>>,
|
manifest: Mutex<Option<DropManifest>>,
|
||||||
pub progress: Arc<ProgressObject>,
|
progress: Arc<ProgressObject>,
|
||||||
sender: Sender<DownloadManagerSignal>,
|
sender: Sender<DownloadManagerSignal>,
|
||||||
pub stored_manifest: StoredManifest,
|
stored_manifest: StoredManifest,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,2 @@
|
|||||||
pub mod download_agent;
|
pub mod download_agent;
|
||||||
pub mod download_commands;
|
pub mod download_commands;
|
||||||
mod download_logic;
|
|
||||||
mod manifest;
|
|
||||||
mod stored_manifest;
|
|
||||||
|
|||||||
@ -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,4 +1,3 @@
|
|||||||
mod external_component;
|
|
||||||
mod prefix;
|
mod prefix;
|
||||||
mod registry;
|
mod registry;
|
||||||
mod tool;
|
mod tool;
|
||||||
@ -1,7 +1,8 @@
|
|||||||
use std::collections::HashMap;
|
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>
|
tools: HashMap<String, T>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -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 {
|
use crate::download_manager::{download_thread_control_flag::DownloadThreadControl, downloadable::Downloadable, progress_object::ProgressObject};
|
||||||
name: String,
|
|
||||||
|
pub struct ToolDownloader {
|
||||||
|
id: String,
|
||||||
version: String,
|
version: String,
|
||||||
location: Option<PathBuf>,
|
location: Option<PathBuf>,
|
||||||
|
progress: Arc<ProgressObject>,
|
||||||
|
control_flag: DownloadThreadControl
|
||||||
}
|
}
|
||||||
impl ExternalComponent for Tool {
|
impl Downloadable for ToolDownloader {
|
||||||
fn download(&mut self) {
|
fn get_progress_object(&self) -> std::sync::Arc<crate::download_manager::progress_object::ProgressObject> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn version(&self) -> &String {
|
fn version(&self) -> String {
|
||||||
&self.version
|
self.version.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_installed(&self) -> bool {
|
fn id(&self) -> String {
|
||||||
self.location.is_some()
|
self.id.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn location(&self) -> &Option<PathBuf> {
|
fn download(&mut self) -> Result<(), crate::download_manager::application_download_error::ApplicationDownloadError> {
|
||||||
&self.location
|
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()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user