mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 08:12:44 +10:00
refactor: Ran cargo clippy & fmt
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
use crate::DB;
|
||||
use log::info;
|
||||
use tauri::AppHandle;
|
||||
use tauri_plugin_autostart::ManagerExt;
|
||||
use crate::DB;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn toggle_autostart(app: AppHandle, enabled: bool) -> Result<(), String> {
|
||||
|
||||
@ -1,8 +1,6 @@
|
||||
|
||||
use log::info;
|
||||
use tauri::AppHandle;
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
pub fn quit(app: tauri::AppHandle) {
|
||||
cleanup_and_exit(&app);
|
||||
|
||||
@ -2,7 +2,7 @@ use std::{
|
||||
collections::HashMap,
|
||||
fs::{self, create_dir_all},
|
||||
path::{Path, PathBuf},
|
||||
sync::{Arc, LazyLock, Mutex, RwLockWriteGuard}, time::{Instant, SystemTime, UNIX_EPOCH},
|
||||
sync::{LazyLock, Mutex, RwLockWriteGuard},
|
||||
};
|
||||
|
||||
use chrono::Utc;
|
||||
@ -14,7 +14,12 @@ use serde_with::serde_as;
|
||||
use tauri::AppHandle;
|
||||
use url::Url;
|
||||
|
||||
use crate::{download_manager::downloadable_metadata::DownloadableMetadata, games::{library::push_game_update, state::GameStatusManager}, process::process_manager::Platform, DB};
|
||||
use crate::{
|
||||
download_manager::downloadable_metadata::DownloadableMetadata,
|
||||
games::{library::push_game_update, state::GameStatusManager},
|
||||
process::process_manager::Platform,
|
||||
DB,
|
||||
};
|
||||
|
||||
#[derive(serde::Serialize, Clone, Deserialize)]
|
||||
pub struct DatabaseAuth {
|
||||
@ -71,21 +76,12 @@ pub struct DatabaseApplications {
|
||||
pub transient_statuses: HashMap<DownloadableMetadata, ApplicationTransientStatus>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||
pub struct Settings {
|
||||
pub autostart: bool,
|
||||
// ... other settings ...
|
||||
}
|
||||
|
||||
impl Default for Settings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
autostart: false,
|
||||
// ... other settings defaults ...
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
pub struct Database {
|
||||
#[serde(default)]
|
||||
@ -93,7 +89,7 @@ pub struct Database {
|
||||
pub auth: Option<DatabaseAuth>,
|
||||
pub base_url: String,
|
||||
pub applications: DatabaseApplications,
|
||||
pub prev_database: Option<PathBuf>
|
||||
pub prev_database: Option<PathBuf>,
|
||||
}
|
||||
pub static DATA_ROOT_DIR: LazyLock<Mutex<PathBuf>> =
|
||||
LazyLock::new(|| Mutex::new(BaseDirs::new().unwrap().data_dir().join("drop")));
|
||||
@ -137,8 +133,7 @@ impl DatabaseImpls for DatabaseInterface {
|
||||
let exists = fs::exists(db_path.clone()).unwrap();
|
||||
|
||||
match exists {
|
||||
true =>
|
||||
match PathDatabase::load_from_path(db_path.clone()) {
|
||||
true => match PathDatabase::load_from_path(db_path.clone()) {
|
||||
Ok(db) => db,
|
||||
Err(e) => handle_invalid_database(e, db_path, games_base_dir),
|
||||
},
|
||||
@ -247,7 +242,11 @@ pub fn set_game_status<F: FnOnce(&mut RwLockWriteGuard<'_, Database>, &Downloada
|
||||
}
|
||||
|
||||
// TODO: Make the error relelvant rather than just assume that it's a Deserialize error
|
||||
fn handle_invalid_database(_e: RustbreakError, db_path: PathBuf, games_base_dir: PathBuf) -> rustbreak::Database<Database, rustbreak::backend::PathBackend, DropDatabaseSerializer> {
|
||||
fn handle_invalid_database(
|
||||
_e: RustbreakError,
|
||||
db_path: PathBuf,
|
||||
games_base_dir: PathBuf,
|
||||
) -> rustbreak::Database<Database, rustbreak::backend::PathBackend, DropDatabaseSerializer> {
|
||||
let new_path = {
|
||||
let time = Utc::now().timestamp();
|
||||
let mut base = db_path.clone().into_os_string();
|
||||
@ -271,8 +270,5 @@ fn handle_invalid_database(_e: RustbreakError, db_path: PathBuf, games_base_dir:
|
||||
settings: Settings { autostart: false },
|
||||
};
|
||||
|
||||
PathDatabase::create_at_path(db_path, db)
|
||||
.expect("Database could not be created")
|
||||
|
||||
|
||||
PathDatabase::create_at_path(db_path, db).expect("Database could not be created")
|
||||
}
|
||||
@ -1,4 +1,7 @@
|
||||
use std::{fmt::{Display, Formatter}, io};
|
||||
use std::{
|
||||
fmt::{Display, Formatter},
|
||||
io,
|
||||
};
|
||||
|
||||
use crate::remote::RemoteAccessError;
|
||||
|
||||
@ -38,4 +41,3 @@ impl Display for SetupError {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ use std::{
|
||||
fmt::Debug,
|
||||
sync::{
|
||||
mpsc::{SendError, Sender},
|
||||
Arc, Mutex, MutexGuard,
|
||||
MutexGuard,
|
||||
},
|
||||
thread::JoinHandle,
|
||||
};
|
||||
@ -12,8 +12,12 @@ use std::{
|
||||
use log::info;
|
||||
use serde::Serialize;
|
||||
|
||||
|
||||
use super::{application_download_error::ApplicationDownloadError, download_manager_builder::{CurrentProgressObject, DownloadAgent}, downloadable_metadata::DownloadableMetadata, queue::Queue};
|
||||
use super::{
|
||||
application_download_error::ApplicationDownloadError,
|
||||
download_manager_builder::{CurrentProgressObject, DownloadAgent},
|
||||
downloadable_metadata::DownloadableMetadata,
|
||||
queue::Queue,
|
||||
};
|
||||
|
||||
pub enum DownloadManagerSignal {
|
||||
/// Resumes (or starts) the DownloadManager
|
||||
@ -103,10 +107,11 @@ impl DownloadManager {
|
||||
|
||||
pub fn queue_download(
|
||||
&self,
|
||||
download: DownloadAgent
|
||||
download: DownloadAgent,
|
||||
) -> Result<(), SendError<DownloadManagerSignal>> {
|
||||
info!("Adding download id {:?}", download.metadata());
|
||||
self.command_sender.send(DownloadManagerSignal::Queue(download))?;
|
||||
self.command_sender
|
||||
.send(DownloadManagerSignal::Queue(download))?;
|
||||
self.command_sender.send(DownloadManagerSignal::Go)
|
||||
}
|
||||
pub fn edit(&self) -> MutexGuard<'_, VecDeque<DownloadableMetadata>> {
|
||||
|
||||
@ -1,19 +1,26 @@
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs::remove_dir_all,
|
||||
sync::{
|
||||
mpsc::{channel, Receiver, Sender},
|
||||
Arc, Mutex, RwLockWriteGuard,
|
||||
Arc, Mutex,
|
||||
},
|
||||
thread::{spawn, JoinHandle},
|
||||
};
|
||||
|
||||
use log::{error, info};
|
||||
use log::info;
|
||||
use tauri::{AppHandle, Emitter};
|
||||
|
||||
use crate::games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent};
|
||||
|
||||
use super::{application_download_error::ApplicationDownloadError, download_manager::{DownloadManager, DownloadManagerSignal, DownloadManagerStatus}, download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag}, downloadable::Downloadable, downloadable_metadata::DownloadableMetadata, progress_object::ProgressObject, queue::Queue};
|
||||
use super::{
|
||||
application_download_error::ApplicationDownloadError,
|
||||
download_manager::{DownloadManager, DownloadManagerSignal, DownloadManagerStatus},
|
||||
download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag},
|
||||
downloadable::Downloadable,
|
||||
downloadable_metadata::DownloadableMetadata,
|
||||
progress_object::ProgressObject,
|
||||
queue::Queue,
|
||||
};
|
||||
|
||||
pub type DownloadAgent = Arc<Box<dyn Downloadable + Send + Sync>>;
|
||||
pub type CurrentProgressObject = Arc<Mutex<Option<Arc<ProgressObject>>>>;
|
||||
@ -115,7 +122,6 @@ impl DownloadManagerBuilder {
|
||||
let mut download_thread_lock = self.current_download_thread.lock().unwrap();
|
||||
*download_thread_lock = None;
|
||||
drop(download_thread_lock);
|
||||
|
||||
}
|
||||
|
||||
fn stop_and_wait_current_download(&self) {
|
||||
@ -130,7 +136,6 @@ impl DownloadManagerBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn manage_queue(mut self) -> Result<(), ()> {
|
||||
loop {
|
||||
let signal = match self.command_receiver.recv() {
|
||||
@ -186,18 +191,26 @@ impl DownloadManagerBuilder {
|
||||
self.download_queue.append(meta.clone());
|
||||
self.download_agent_registry.insert(meta, download_agent);
|
||||
|
||||
self.sender.send(DownloadManagerSignal::UpdateUIQueue).unwrap();
|
||||
self.sender
|
||||
.send(DownloadManagerSignal::UpdateUIQueue)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn manage_go_signal(&mut self) {
|
||||
info!("Got signal Go");
|
||||
if self.download_agent_registry.is_empty() {
|
||||
info!("Download agent registry: {:?}", self.download_agent_registry.len());
|
||||
info!(
|
||||
"Download agent registry: {:?}",
|
||||
self.download_agent_registry.len()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if self.current_download_agent.is_some() {
|
||||
info!("Current download agent: {:?}", self.current_download_agent.as_ref().unwrap().metadata());
|
||||
info!(
|
||||
"Current download agent: {:?}",
|
||||
self.current_download_agent.as_ref().unwrap().metadata()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -227,16 +240,18 @@ impl DownloadManagerBuilder {
|
||||
// Ok(true) is for completed and exited properly
|
||||
Ok(true) => {
|
||||
download_agent.on_complete(&app_handle);
|
||||
sender.send(DownloadManagerSignal::Completed(download_agent.metadata())).unwrap();
|
||||
},
|
||||
sender
|
||||
.send(DownloadManagerSignal::Completed(download_agent.metadata()))
|
||||
.unwrap();
|
||||
}
|
||||
// Ok(false) is for incomplete but exited properly
|
||||
Ok(false) => {
|
||||
download_agent.on_incomplete(&app_handle);
|
||||
},
|
||||
}
|
||||
Err(e) => {
|
||||
download_agent.on_error(&app_handle, e.clone());
|
||||
sender.send(DownloadManagerSignal::Error(e)).unwrap();
|
||||
},
|
||||
}
|
||||
}
|
||||
sender.send(DownloadManagerSignal::UpdateUIQueue).unwrap();
|
||||
}));
|
||||
@ -290,29 +305,32 @@ impl DownloadManagerBuilder {
|
||||
info!("Current donwload queue: {:?}", self.download_queue.read());
|
||||
}
|
||||
// TODO: Collapse these two into a single if statement somehow
|
||||
else {
|
||||
if let Some(download_agent) = self.download_agent_registry.get(meta) {
|
||||
else if let Some(download_agent) = self.download_agent_registry.get(meta) {
|
||||
info!("Object exists in registry");
|
||||
let index = self.download_queue.get_by_meta(meta);
|
||||
if let Some(index) = index {
|
||||
download_agent.on_cancelled(&self.app_handle);
|
||||
let _ = self.download_queue.edit().remove(index).unwrap();
|
||||
let removed = self.download_agent_registry.remove(meta);
|
||||
info!("Removed {:?} from queue {:?}", removed.and_then(|x| Some(x.metadata())), self.download_queue.read());
|
||||
info!(
|
||||
"Removed {:?} from queue {:?}",
|
||||
removed.map(|x| x.metadata()),
|
||||
self.download_queue.read()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if let Some(download_agent) = self.download_agent_registry.get(meta) {
|
||||
} else if let Some(download_agent) = self.download_agent_registry.get(meta) {
|
||||
info!("Object exists in registry");
|
||||
let index = self.download_queue.get_by_meta(meta);
|
||||
if let Some(index) = index {
|
||||
download_agent.on_cancelled(&self.app_handle);
|
||||
let _ = self.download_queue.edit().remove(index).unwrap();
|
||||
let removed = self.download_agent_registry.remove(meta);
|
||||
info!("Removed {:?} from queue {:?}", removed.and_then(|x| Some(x.metadata())), self.download_queue.read());
|
||||
}
|
||||
info!(
|
||||
"Removed {:?} from queue {:?}",
|
||||
removed.map(|x| x.metadata()),
|
||||
self.download_queue.read()
|
||||
);
|
||||
}
|
||||
}
|
||||
self.push_ui_queue_update();
|
||||
@ -326,18 +344,17 @@ impl DownloadManagerBuilder {
|
||||
let queue = &self.download_queue.read();
|
||||
let queue_objs = queue
|
||||
.iter()
|
||||
.map(|(key)| {
|
||||
.map(|key| {
|
||||
let val = self.download_agent_registry.get(key).unwrap();
|
||||
QueueUpdateEventQueueData {
|
||||
meta: DownloadableMetadata::clone(&key),
|
||||
meta: DownloadableMetadata::clone(key),
|
||||
status: val.status(),
|
||||
progress: val.progress().get_progress()
|
||||
}})
|
||||
progress: val.progress().get_progress(),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
let event_data = QueueUpdateEvent {
|
||||
queue: queue_objs,
|
||||
};
|
||||
let event_data = QueueUpdateEvent { queue: queue_objs };
|
||||
self.app_handle.emit("update_queue", event_data).unwrap();
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
use std::{fmt::{self, Debug}, sync::{mpsc::Sender, Arc}};
|
||||
use std::sync::Arc;
|
||||
|
||||
use tauri::AppHandle;
|
||||
|
||||
use super::{
|
||||
application_download_error::ApplicationDownloadError, download_manager::{DownloadManagerSignal, DownloadStatus}, download_thread_control_flag::DownloadThreadControl, downloadable_metadata::DownloadableMetadata, progress_object::ProgressObject
|
||||
application_download_error::ApplicationDownloadError, download_manager::DownloadStatus,
|
||||
download_thread_control_flag::DownloadThreadControl,
|
||||
downloadable_metadata::DownloadableMetadata, progress_object::ProgressObject,
|
||||
};
|
||||
|
||||
pub trait Downloadable: Send + Sync {
|
||||
|
||||
@ -5,7 +5,7 @@ pub enum DownloadType {
|
||||
Game,
|
||||
Tool,
|
||||
DLC,
|
||||
Mod
|
||||
Mod,
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone)]
|
||||
@ -13,14 +13,14 @@ pub enum DownloadType {
|
||||
pub struct DownloadableMetadata {
|
||||
pub id: String,
|
||||
pub version: Option<String>,
|
||||
pub download_type: DownloadType
|
||||
pub download_type: DownloadType,
|
||||
}
|
||||
impl DownloadableMetadata {
|
||||
pub fn new(id: String, version: Option<String>, download_type: DownloadType) -> Self {
|
||||
Self {
|
||||
id,
|
||||
version,
|
||||
download_type
|
||||
download_type,
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,3 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use super::{download_manager_builder::DownloadAgent, downloadable_metadata::DownloadableMetadata};
|
||||
|
||||
pub fn generate_downloadable(meta: DownloadableMetadata) -> DownloadAgent {
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
pub mod application_download_error;
|
||||
pub mod download_manager;
|
||||
pub mod download_manager_builder;
|
||||
pub mod progress_object;
|
||||
pub mod queue;
|
||||
pub mod download_thread_control_flag;
|
||||
pub mod downloadable;
|
||||
pub mod application_download_error;
|
||||
pub mod downloadable_metadata;
|
||||
pub mod generate_downloadable;
|
||||
pub mod progress_object;
|
||||
pub mod queue;
|
||||
|
||||
@ -98,7 +98,8 @@ impl ProgressObject {
|
||||
|
||||
let amount_since_last_update = current_amount - amount_at_last_update;
|
||||
|
||||
let kilobytes_per_second = amount_since_last_update / (last_update_difference as usize).max(1);
|
||||
let kilobytes_per_second =
|
||||
amount_since_last_update / (last_update_difference as usize).max(1);
|
||||
|
||||
let remaining = max - current_amount; // bytes
|
||||
let time_remaining = (remaining / 1000) / kilobytes_per_second.max(1);
|
||||
|
||||
@ -11,6 +11,12 @@ pub struct Queue {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl Default for Queue {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl Queue {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
@ -44,10 +50,7 @@ impl Queue {
|
||||
pub fn append(&self, interface: DownloadableMetadata) {
|
||||
self.edit().push_back(interface);
|
||||
}
|
||||
pub fn pop_front_if_equal(
|
||||
&self,
|
||||
meta: &DownloadableMetadata,
|
||||
) -> Option<DownloadableMetadata> {
|
||||
pub fn pop_front_if_equal(&self, meta: &DownloadableMetadata) -> Option<DownloadableMetadata> {
|
||||
let mut queue = self.edit();
|
||||
let front = match queue.front() {
|
||||
Some(front) => front,
|
||||
@ -61,7 +64,11 @@ impl Queue {
|
||||
pub fn get_by_meta(&self, meta: &DownloadableMetadata) -> Option<usize> {
|
||||
self.read().iter().position(|data| data == meta)
|
||||
}
|
||||
pub fn move_to_index_by_meta(&self, meta: &DownloadableMetadata, new_index: usize) -> Result<(), ()> {
|
||||
pub fn move_to_index_by_meta(
|
||||
&self,
|
||||
meta: &DownloadableMetadata,
|
||||
new_index: usize,
|
||||
) -> Result<(), ()> {
|
||||
let index = match self.get_by_meta(meta) {
|
||||
Some(index) => index,
|
||||
None => return Err(()),
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
use crate::auth::generate_authorization_header;
|
||||
use crate::db::{set_game_status, GameDownloadStatus, ApplicationTransientStatus, DatabaseImpls};
|
||||
use crate::db::{set_game_status, ApplicationTransientStatus, DatabaseImpls};
|
||||
use crate::download_manager::application_download_error::ApplicationDownloadError;
|
||||
use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus};
|
||||
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_metadata::{DownloadType, DownloadableMetadata};
|
||||
use crate::download_manager::progress_object::{ProgressHandle, ProgressObject};
|
||||
@ -12,14 +14,13 @@ use crate::remote::RemoteAccessError;
|
||||
use crate::DB;
|
||||
use log::{debug, error, info};
|
||||
use rayon::ThreadPoolBuilder;
|
||||
use tauri::{AppHandle, Emitter};
|
||||
use std::collections::VecDeque;
|
||||
use std::fs::{create_dir_all, remove_dir_all, File};
|
||||
use std::fs::{create_dir_all, File};
|
||||
use std::path::Path;
|
||||
use std::sync::mpsc::Sender;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::thread::spawn;
|
||||
use std::time::Instant;
|
||||
use tauri::{AppHandle, Emitter};
|
||||
use urlencoding::encode;
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
@ -38,7 +39,7 @@ pub struct GameDownloadAgent {
|
||||
pub progress: Arc<ProgressObject>,
|
||||
sender: Sender<DownloadManagerSignal>,
|
||||
pub stored_manifest: StoredManifest,
|
||||
status: Mutex<DownloadStatus>
|
||||
status: Mutex<DownloadStatus>,
|
||||
}
|
||||
|
||||
impl GameDownloadAgent {
|
||||
@ -96,8 +97,19 @@ impl GameDownloadAgent {
|
||||
self.set_progress_object_params();
|
||||
info!("Running");
|
||||
let timer = Instant::now();
|
||||
push_game_update(app_handle, &self.metadata(), (None, Some(ApplicationTransientStatus::Downloading { version_name: self.version.clone() })));
|
||||
let res = self.run().map_err(|_| ApplicationDownloadError::DownloadError);
|
||||
push_game_update(
|
||||
app_handle,
|
||||
&self.metadata(),
|
||||
(
|
||||
None,
|
||||
Some(ApplicationTransientStatus::Downloading {
|
||||
version_name: self.version.clone(),
|
||||
}),
|
||||
),
|
||||
);
|
||||
let res = self
|
||||
.run()
|
||||
.map_err(|_| ApplicationDownloadError::DownloadError);
|
||||
|
||||
info!(
|
||||
"{} took {}ms to download",
|
||||
@ -192,12 +204,10 @@ impl GameDownloadAgent {
|
||||
let base_path = Path::new(&self.stored_manifest.base_path);
|
||||
create_dir_all(base_path).unwrap();
|
||||
|
||||
|
||||
{
|
||||
let mut completed_contexts_lock = self.completed_contexts.lock().unwrap();
|
||||
completed_contexts_lock.clear();
|
||||
completed_contexts_lock
|
||||
.extend(self.stored_manifest.get_completed_contexts());
|
||||
completed_contexts_lock.extend(self.stored_manifest.get_completed_contexts());
|
||||
}
|
||||
|
||||
for (raw_path, chunk) in manifest {
|
||||
@ -248,8 +258,6 @@ impl GameDownloadAgent {
|
||||
|
||||
let base_url = DB.fetch_base_url();
|
||||
|
||||
|
||||
|
||||
let contexts = self.contexts.lock().unwrap();
|
||||
pool.scope(|scope| {
|
||||
let client = &reqwest::blocking::Client::new();
|
||||
@ -267,11 +275,11 @@ impl GameDownloadAgent {
|
||||
|
||||
let sender = self.sender.clone();
|
||||
|
||||
let request = generate_request(&base_url, client, &context);
|
||||
|
||||
let request = generate_request(&base_url, client, context);
|
||||
|
||||
scope.spawn(move |_| {
|
||||
match download_game_chunk(context, &self.control_flag, progress_handle, request) {
|
||||
match download_game_chunk(context, &self.control_flag, progress_handle, request)
|
||||
{
|
||||
Ok(res) => {
|
||||
if res {
|
||||
completed_indexes.push(index);
|
||||
@ -289,7 +297,6 @@ impl GameDownloadAgent {
|
||||
|
||||
let newly_completed = completed_indexes.to_owned();
|
||||
|
||||
|
||||
let completed_lock_len = {
|
||||
let mut completed_contexts_lock = self.completed_contexts.lock().unwrap();
|
||||
for (item, _) in newly_completed.iter() {
|
||||
@ -314,7 +321,6 @@ impl GameDownloadAgent {
|
||||
|
||||
info!("Sending completed signal");
|
||||
|
||||
|
||||
// We've completed
|
||||
self.sender
|
||||
.send(DownloadManagerSignal::Completed(self.metadata()))
|
||||
@ -324,7 +330,11 @@ impl GameDownloadAgent {
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_request(base_url: &url::Url, client: reqwest::blocking::Client, context: &DropDownloadContext) -> reqwest::blocking::RequestBuilder {
|
||||
fn generate_request(
|
||||
base_url: &url::Url,
|
||||
client: reqwest::blocking::Client,
|
||||
context: &DropDownloadContext,
|
||||
) -> reqwest::blocking::RequestBuilder {
|
||||
let chunk_url = base_url
|
||||
.join(&format!(
|
||||
"/api/v1/client/chunk?id={}&version={}&name={}&chunk={}",
|
||||
@ -338,10 +348,7 @@ fn generate_request(base_url: &url::Url, client: reqwest::blocking::Client, cont
|
||||
|
||||
let header = generate_authorization_header();
|
||||
|
||||
let request = client
|
||||
.get(chunk_url)
|
||||
.header("Authorization", header);
|
||||
request
|
||||
client.get(chunk_url).header("Authorization", header)
|
||||
}
|
||||
|
||||
impl Downloadable for GameDownloadAgent {
|
||||
@ -368,7 +375,6 @@ impl Downloadable for GameDownloadAgent {
|
||||
|
||||
fn on_initialised(&self, _app_handle: &tauri::AppHandle) {
|
||||
*self.status.lock().unwrap() = DownloadStatus::Queued;
|
||||
return;
|
||||
}
|
||||
|
||||
fn on_error(&self, app_handle: &tauri::AppHandle, error: ApplicationDownloadError) {
|
||||
@ -382,21 +388,22 @@ impl Downloadable for GameDownloadAgent {
|
||||
set_game_status(app_handle, self.metadata(), |db_handle, meta| {
|
||||
db_handle.applications.transient_statuses.remove(meta);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
fn on_complete(&self, app_handle: &tauri::AppHandle) {
|
||||
on_game_complete(&self.metadata(), self.stored_manifest.base_path.to_string_lossy().to_string(), app_handle).unwrap();
|
||||
on_game_complete(
|
||||
&self.metadata(),
|
||||
self.stored_manifest.base_path.to_string_lossy().to_string(),
|
||||
app_handle,
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
fn on_incomplete(&self, _app_handle: &tauri::AppHandle) {
|
||||
*self.status.lock().unwrap() = DownloadStatus::Queued;
|
||||
return;
|
||||
}
|
||||
|
||||
fn on_cancelled(&self, _app_handle: &tauri::AppHandle) {
|
||||
return;
|
||||
}
|
||||
fn on_cancelled(&self, _app_handle: &tauri::AppHandle) {}
|
||||
|
||||
fn status(&self) -> DownloadStatus {
|
||||
self.status.lock().unwrap().clone()
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use crate::{download_manager::{downloadable::Downloadable, downloadable_metadata::DownloadableMetadata}, AppState};
|
||||
use crate::{
|
||||
download_manager::{downloadable::Downloadable, downloadable_metadata::DownloadableMetadata},
|
||||
AppState,
|
||||
};
|
||||
|
||||
use super::download_agent::GameDownloadAgent;
|
||||
|
||||
@ -12,9 +15,12 @@ pub fn download_game(
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<(), String> {
|
||||
let sender = state.lock().unwrap().download_manager.get_sender();
|
||||
let game_download_agent = Arc::new(
|
||||
Box::new(GameDownloadAgent::new(game_id, game_version, install_dir, sender)) as Box<dyn Downloadable + Send + Sync>
|
||||
);
|
||||
let game_download_agent = Arc::new(Box::new(GameDownloadAgent::new(
|
||||
game_id,
|
||||
game_version,
|
||||
install_dir,
|
||||
sender,
|
||||
)) as Box<dyn Downloadable + Send + Sync>);
|
||||
state
|
||||
.lock()
|
||||
.unwrap()
|
||||
|
||||
@ -1,26 +1,23 @@
|
||||
use crate::auth::generate_authorization_header;
|
||||
use crate::db::DatabaseImpls;
|
||||
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::games::downloads::manifest::DropDownloadContext;
|
||||
use crate::remote::RemoteAccessError;
|
||||
use crate::DB;
|
||||
use log::{error, info, warn};
|
||||
use log::{error, warn};
|
||||
use md5::{Context, Digest};
|
||||
use reqwest::blocking::{Client, Request, RequestBuilder, Response};
|
||||
use reqwest::blocking::{RequestBuilder, Response};
|
||||
|
||||
use std::fs::{set_permissions, Permissions};
|
||||
use std::io::Read;
|
||||
#[cfg(unix)]
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
fs::{File, OpenOptions},
|
||||
io::{self, BufWriter, Seek, SeekFrom, Write},
|
||||
path::PathBuf,
|
||||
};
|
||||
use urlencoding::encode;
|
||||
|
||||
pub struct DropWriter<W: Write> {
|
||||
hasher: Context,
|
||||
@ -124,7 +121,7 @@ pub fn download_game_chunk(
|
||||
ctx: &DropDownloadContext,
|
||||
control_flag: &DownloadThreadControl,
|
||||
progress: ProgressHandle,
|
||||
request: RequestBuilder
|
||||
request: RequestBuilder,
|
||||
) -> Result<bool, ApplicationDownloadError> {
|
||||
// If we're paused
|
||||
if control_flag.get() == DownloadThreadControlFlag::Stop {
|
||||
|
||||
@ -43,8 +43,6 @@ impl StoredManifest {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
match serde_binary::from_vec::<StoredManifest>(s, Endian::Little) {
|
||||
Ok(manifest) => manifest,
|
||||
Err(e) => {
|
||||
|
||||
@ -2,19 +2,19 @@ use std::fs::remove_dir_all;
|
||||
use std::sync::Mutex;
|
||||
use std::thread::spawn;
|
||||
|
||||
use log::{error, info, warn};
|
||||
use log::{error, info};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri::Emitter;
|
||||
use tauri::{AppHandle, Manager};
|
||||
use urlencoding::encode;
|
||||
|
||||
use crate::db::{ApplicationTransientStatus, DatabaseImpls, GameDownloadStatus};
|
||||
use crate::db::GameVersion;
|
||||
use crate::db::{ApplicationTransientStatus, DatabaseImpls, GameDownloadStatus};
|
||||
use crate::download_manager::download_manager::DownloadStatus;
|
||||
use crate::download_manager::downloadable_metadata::DownloadableMetadata;
|
||||
use crate::games::state::{GameStatusManager, GameStatusWithTransient};
|
||||
use crate::process::process_manager::Platform;
|
||||
use crate::remote::RemoteAccessError;
|
||||
use crate::games::state::{GameStatusManager, GameStatusWithTransient};
|
||||
use crate::{auth::generate_authorization_header, AppState, DB};
|
||||
|
||||
#[derive(serde::Serialize)]
|
||||
@ -40,7 +40,10 @@ pub struct Game {
|
||||
#[derive(serde::Serialize, Clone)]
|
||||
pub struct GameUpdateEvent {
|
||||
pub game_id: String,
|
||||
pub status: (Option<GameDownloadStatus>, Option<ApplicationTransientStatus>),
|
||||
pub status: (
|
||||
Option<GameDownloadStatus>,
|
||||
Option<ApplicationTransientStatus>,
|
||||
),
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone)]
|
||||
@ -237,7 +240,7 @@ fn fetch_game_verion_options_logic<'a>(
|
||||
pub fn uninstall_game(
|
||||
game_id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
app_handle: AppHandle
|
||||
app_handle: AppHandle,
|
||||
) -> Result<(), String> {
|
||||
let meta = get_current_meta(&game_id)?;
|
||||
println!("{:?}", meta);
|
||||
@ -303,14 +306,24 @@ fn uninstall_game_logic(meta: DownloadableMetadata, app_handle: &AppHandle) {
|
||||
|
||||
info!("uninstalled game id {}", &meta.id);
|
||||
|
||||
push_game_update(&app_handle, &meta, (Some(GameDownloadStatus::Remote {}), None));
|
||||
push_game_update(
|
||||
&app_handle,
|
||||
&meta,
|
||||
(Some(GameDownloadStatus::Remote {}), None),
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_current_meta(game_id: &String) -> Result<DownloadableMetadata, String> {
|
||||
match DB.borrow_data().unwrap().applications.installed_game_version.get(game_id) {
|
||||
match DB
|
||||
.borrow_data()
|
||||
.unwrap()
|
||||
.applications
|
||||
.installed_game_version
|
||||
.get(game_id)
|
||||
{
|
||||
Some(meta) => Ok(meta.clone()),
|
||||
None => Err(String::from("Could not find installed version")),
|
||||
}
|
||||
@ -331,7 +344,9 @@ pub fn on_game_complete(
|
||||
) -> Result<(), RemoteAccessError> {
|
||||
// Fetch game version information from remote
|
||||
let base_url = DB.fetch_base_url();
|
||||
if meta.version.is_none() { return Err(RemoteAccessError::GameNotFound) }
|
||||
if meta.version.is_none() {
|
||||
return Err(RemoteAccessError::GameNotFound);
|
||||
}
|
||||
|
||||
let endpoint = base_url.join(
|
||||
format!(
|
||||
@ -398,7 +413,11 @@ pub fn on_game_complete(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn push_game_update(app_handle: &AppHandle, meta: &DownloadableMetadata, status: GameStatusWithTransient) {
|
||||
pub fn push_game_update(
|
||||
app_handle: &AppHandle,
|
||||
meta: &DownloadableMetadata,
|
||||
status: GameStatusWithTransient,
|
||||
) {
|
||||
app_handle
|
||||
.emit(
|
||||
&format!("update_game/{}", meta.id),
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
use crate::{
|
||||
db::{ApplicationTransientStatus, GameDownloadStatus}, download_manager::downloadable_metadata::{DownloadType, DownloadableMetadata}, fetch_state, DB
|
||||
db::{ApplicationTransientStatus, GameDownloadStatus},
|
||||
DB,
|
||||
};
|
||||
|
||||
pub type GameStatusWithTransient = (Option<GameDownloadStatus>, Option<ApplicationTransientStatus>);
|
||||
pub type GameStatusWithTransient = (
|
||||
Option<GameDownloadStatus>,
|
||||
Option<ApplicationTransientStatus>,
|
||||
);
|
||||
pub struct GameStatusManager {}
|
||||
|
||||
impl GameStatusManager {
|
||||
pub fn fetch_state(game_id: &String) -> GameStatusWithTransient {
|
||||
let db_lock = DB.borrow_data().unwrap();
|
||||
let online_state = match db_lock.applications.installed_game_version.get(game_id) {
|
||||
Some(meta) => db_lock
|
||||
.applications
|
||||
.transient_statuses
|
||||
.get(meta)
|
||||
.cloned(),
|
||||
Some(meta) => db_lock.applications.transient_statuses.get(meta).cloned(),
|
||||
None => None,
|
||||
};
|
||||
let offline_state = db_lock.applications.game_statuses.get(game_id).cloned();
|
||||
|
||||
@ -5,12 +5,12 @@ mod games;
|
||||
mod autostart;
|
||||
mod cleanup;
|
||||
mod debug;
|
||||
pub mod download_manager;
|
||||
mod process;
|
||||
mod remote;
|
||||
mod tools;
|
||||
pub mod download_manager;
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
mod tools;
|
||||
|
||||
use crate::autostart::{get_autostart_enabled, toggle_autostart};
|
||||
use crate::db::DatabaseImpls;
|
||||
@ -20,18 +20,20 @@ use auth::{
|
||||
};
|
||||
use cleanup::{cleanup_and_exit, quit};
|
||||
use db::{
|
||||
add_download_dir, delete_download_dir, fetch_download_dir_stats, DatabaseInterface, GameDownloadStatus,
|
||||
DATA_ROOT_DIR,
|
||||
add_download_dir, delete_download_dir, fetch_download_dir_stats, DatabaseInterface,
|
||||
GameDownloadStatus, DATA_ROOT_DIR,
|
||||
};
|
||||
use debug::fetch_system_data;
|
||||
use download_manager::download_manager::DownloadManager;
|
||||
use download_manager::download_manager_builder::DownloadManagerBuilder;
|
||||
use games::downloads::download_commands::{cancel_game, download_game, move_game_in_queue, pause_game_downloads, resume_game_downloads};
|
||||
use games::downloads::download_commands::{
|
||||
cancel_game, download_game, move_game_in_queue, pause_game_downloads, resume_game_downloads,
|
||||
};
|
||||
use games::library::{
|
||||
fetch_game, fetch_game_status, fetch_game_verion_options, fetch_library, uninstall_game, Game,
|
||||
};
|
||||
use http::Response;
|
||||
use http::{header::*, response::Builder as ResponseBuilder};
|
||||
use games::library::{
|
||||
fetch_game, fetch_game_status, fetch_game_verion_options, fetch_library, uninstall_game, Game
|
||||
};
|
||||
use log::{debug, info, warn, LevelFilter};
|
||||
use log4rs::append::console::ConsoleAppender;
|
||||
use log4rs::append::file::FileAppender;
|
||||
@ -43,7 +45,6 @@ use process::process_commands::{kill_game, launch_game};
|
||||
use process::process_manager::ProcessManager;
|
||||
use remote::{gen_drop_url, use_remote};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
use std::path::Path;
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
@ -52,8 +53,9 @@ use std::{
|
||||
};
|
||||
use tauri::menu::{Menu, MenuItem, PredefinedMenuItem};
|
||||
use tauri::tray::TrayIconBuilder;
|
||||
use tauri::{AppHandle, Emitter, Manager, RunEvent, WindowEvent};
|
||||
use tauri::{AppHandle, Manager, RunEvent, WindowEvent};
|
||||
use tauri_plugin_deep_link::DeepLinkExt;
|
||||
use tauri_plugin_dialog::DialogExt;
|
||||
|
||||
#[derive(Clone, Copy, Serialize)]
|
||||
pub enum AppStatus {
|
||||
@ -186,7 +188,6 @@ fn setup(handle: AppHandle) -> AppState<'static> {
|
||||
|
||||
drop(db_handle);
|
||||
|
||||
|
||||
info!("finished setup!");
|
||||
|
||||
// Sync autostart state
|
||||
@ -335,15 +336,24 @@ pub fn run() {
|
||||
{
|
||||
let mut db_handle = DB.borrow_data_mut().unwrap();
|
||||
if let Some(original) = db_handle.prev_database.take() {
|
||||
warn!("Database corrupted. Original file at {}", original.canonicalize().unwrap().to_string_lossy().to_string());
|
||||
warn!(
|
||||
"Database corrupted. Original file at {}",
|
||||
original
|
||||
.canonicalize()
|
||||
.unwrap()
|
||||
.to_string_lossy()
|
||||
.to_string()
|
||||
);
|
||||
app.dialog()
|
||||
.message("Database corrupted. A copy has been saved at: ".to_string() + original.to_str().unwrap())
|
||||
.message(
|
||||
"Database corrupted. A copy has been saved at: ".to_string()
|
||||
+ original.to_str().unwrap(),
|
||||
)
|
||||
.title("Database corrupted")
|
||||
.show(|_| {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.register_asynchronous_uri_scheme_protocol("object", move |_ctx, request, responder| {
|
||||
|
||||
@ -46,6 +46,4 @@ impl CompatibilityManager {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,24 +1,41 @@
|
||||
use std::sync::Mutex;
|
||||
|
||||
use crate::{db::GameDownloadStatus, download_manager::downloadable_metadata::{DownloadType, DownloadableMetadata}, games::library::get_current_meta, AppState, DB};
|
||||
use crate::{
|
||||
db::GameDownloadStatus,
|
||||
download_manager::downloadable_metadata::{DownloadType, DownloadableMetadata},
|
||||
games::library::get_current_meta,
|
||||
AppState, DB,
|
||||
};
|
||||
|
||||
#[tauri::command]
|
||||
pub fn launch_game(
|
||||
id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<(), String> {
|
||||
pub fn launch_game(id: String, state: tauri::State<'_, Mutex<AppState>>) -> Result<(), String> {
|
||||
let state_lock = state.lock().unwrap();
|
||||
let mut process_manager_lock = state_lock.process_manager.lock().unwrap();
|
||||
|
||||
let version = match DB.borrow_data().unwrap().applications.game_statuses.get(&id).cloned() {
|
||||
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"))
|
||||
let version = match DB
|
||||
.borrow_data()
|
||||
.unwrap()
|
||||
.applications
|
||||
.game_statuses
|
||||
.get(&id)
|
||||
.cloned()
|
||||
{
|
||||
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")),
|
||||
};
|
||||
|
||||
|
||||
let meta = DownloadableMetadata { id, version: Some(version), download_type: DownloadType::Game };
|
||||
|
||||
let meta = DownloadableMetadata {
|
||||
id,
|
||||
version: Some(version),
|
||||
download_type: DownloadType::Game,
|
||||
};
|
||||
|
||||
process_manager_lock.launch_process(meta)?;
|
||||
|
||||
@ -29,12 +46,11 @@ pub fn launch_game(
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn kill_game(
|
||||
game_id: String,
|
||||
state: tauri::State<'_, Mutex<AppState>>,
|
||||
) -> Result<(), String> {
|
||||
pub fn kill_game(game_id: String, state: tauri::State<'_, Mutex<AppState>>) -> Result<(), String> {
|
||||
let meta = get_current_meta(&game_id)?;
|
||||
let state_lock = state.lock().unwrap();
|
||||
let mut process_manager_lock = state_lock.process_manager.lock().unwrap();
|
||||
process_manager_lock.kill_game(meta).map_err(|x| x.to_string())
|
||||
process_manager_lock
|
||||
.kill_game(meta)
|
||||
.map_err(|x| x.to_string())
|
||||
}
|
||||
@ -15,7 +15,11 @@ use tauri::{AppHandle, Manager};
|
||||
use umu_wrapper_lib::command_builder::UmuCommandBuilder;
|
||||
|
||||
use crate::{
|
||||
db::{GameDownloadStatus, ApplicationTransientStatus, DATA_ROOT_DIR}, download_manager::{downloadable::Downloadable, downloadable_metadata::DownloadableMetadata}, games::library::push_game_update, games::state::GameStatusManager, AppState, DB
|
||||
db::{ApplicationTransientStatus, GameDownloadStatus, DATA_ROOT_DIR},
|
||||
download_manager::downloadable_metadata::DownloadableMetadata,
|
||||
games::library::push_game_update,
|
||||
games::state::GameStatusManager,
|
||||
AppState, DB,
|
||||
};
|
||||
|
||||
pub struct ProcessManager<'a> {
|
||||
@ -85,7 +89,7 @@ impl ProcessManager<'_> {
|
||||
child.kill()?;
|
||||
child.wait()?;
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
None => Err(io::Error::new(
|
||||
io::ErrorKind::NotFound,
|
||||
"Game ID not running",
|
||||
@ -93,7 +97,11 @@ impl ProcessManager<'_> {
|
||||
};
|
||||
}
|
||||
|
||||
fn on_process_finish(&mut self, meta: DownloadableMetadata, result: Result<ExitStatus, std::io::Error>) {
|
||||
fn on_process_finish(
|
||||
&mut self,
|
||||
meta: DownloadableMetadata,
|
||||
result: Result<ExitStatus, std::io::Error>,
|
||||
) {
|
||||
if !self.processes.contains_key(&meta) {
|
||||
warn!("process on_finish was called, but game_id is no longer valid. finished with result: {:?}", result);
|
||||
return;
|
||||
@ -148,7 +156,10 @@ impl ProcessManager<'_> {
|
||||
}
|
||||
|
||||
let mut db_lock = DB.borrow_data_mut().unwrap();
|
||||
info!("Launching process {:?} with games {:?}", meta, db_lock.applications.game_versions);
|
||||
info!(
|
||||
"Launching process {:?} with games {:?}",
|
||||
meta, db_lock.applications.game_versions
|
||||
);
|
||||
|
||||
let game_status = db_lock
|
||||
.applications
|
||||
@ -210,10 +221,12 @@ impl ProcessManager<'_> {
|
||||
.truncate(true)
|
||||
.read(true)
|
||||
.create(true)
|
||||
.open(
|
||||
self.log_output_dir
|
||||
.join(format!("{}-{}-{}.log", meta.id.clone(), meta.version.clone().unwrap_or_default(), current_time.timestamp())),
|
||||
)
|
||||
.open(self.log_output_dir.join(format!(
|
||||
"{}-{}-{}.log",
|
||||
meta.id.clone(),
|
||||
meta.version.clone().unwrap_or_default(),
|
||||
current_time.timestamp()
|
||||
)))
|
||||
.map_err(|v| v.to_string())?;
|
||||
|
||||
let error_file = OpenOptions::new()
|
||||
|
||||
@ -6,7 +6,6 @@ use std::{
|
||||
|
||||
use http::StatusCode;
|
||||
use log::{info, warn};
|
||||
use reqwest::blocking::Response;
|
||||
use serde::Deserialize;
|
||||
use url::{ParseError, Url};
|
||||
|
||||
|
||||
@ -1,3 +1 @@
|
||||
pub struct CompatibilityLayer {
|
||||
|
||||
}
|
||||
pub struct CompatibilityLayer {}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
mod compatibility_layer;
|
||||
mod prefix;
|
||||
mod registry;
|
||||
mod tool;
|
||||
mod compatibility_layer;
|
||||
@ -0,0 +1 @@
|
||||
|
||||
|
||||
@ -3,5 +3,5 @@ use std::collections::HashMap;
|
||||
use crate::download_manager::downloadable::Downloadable;
|
||||
|
||||
pub struct Registry<T: Downloadable> {
|
||||
tools: HashMap<String, T>
|
||||
tools: HashMap<String, T>,
|
||||
}
|
||||
|
||||
@ -2,7 +2,11 @@ use std::sync::Arc;
|
||||
|
||||
use tauri::AppHandle;
|
||||
|
||||
use crate::download_manager::{application_download_error::ApplicationDownloadError, download_thread_control_flag::DownloadThreadControl, downloadable::Downloadable, downloadable_metadata::DownloadableMetadata, progress_object::ProgressObject};
|
||||
use crate::download_manager::{
|
||||
application_download_error::ApplicationDownloadError,
|
||||
download_thread_control_flag::DownloadThreadControl, downloadable::Downloadable,
|
||||
downloadable_metadata::DownloadableMetadata, progress_object::ProgressObject,
|
||||
};
|
||||
|
||||
pub struct ToolDownloadAgent {
|
||||
id: String,
|
||||
@ -36,7 +40,11 @@ impl Downloadable for ToolDownloadAgent {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn on_error(&self, app_handle: &tauri::AppHandle, error: crate::download_manager::application_download_error::ApplicationDownloadError) {
|
||||
fn on_error(
|
||||
&self,
|
||||
app_handle: &tauri::AppHandle,
|
||||
error: crate::download_manager::application_download_error::ApplicationDownloadError,
|
||||
) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user