mirror of
https://github.com/Drop-OSS/drop.git
synced 2026-07-25 09:14:54 +10:00
refactor: Reorganise file structure
Signed-off-by: quexeky <git@quexeky.dev>
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
pub mod autostart;
|
||||||
|
pub mod cleanup;
|
||||||
|
pub mod commands;
|
||||||
@@ -6,14 +6,12 @@ use std::{
|
|||||||
|
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::{
|
use crate::{database::db::borrow_db_mut_checked, error::download_manager_error::DownloadManagerError};
|
||||||
database::{db::borrow_db_mut_checked},
|
|
||||||
download_manager::internal_error::InternalError,
|
|
||||||
};
|
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
db::{borrow_db_checked, save_db, DATA_ROOT_DIR},
|
db::{borrow_db_checked, save_db, DATA_ROOT_DIR},
|
||||||
debug::SystemData, models::data::Settings,
|
debug::SystemData,
|
||||||
|
models::data::Settings,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Will, in future, return disk/remaining size
|
// Will, in future, return disk/remaining size
|
||||||
@@ -33,7 +31,7 @@ pub fn delete_download_dir(index: usize) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn add_download_dir(new_dir: PathBuf) -> Result<(), InternalError<()>> {
|
pub fn add_download_dir(new_dir: PathBuf) -> Result<(), DownloadManagerError<()>> {
|
||||||
// Check the new directory is all good
|
// Check the new directory is all good
|
||||||
let new_dir_path = Path::new(&new_dir);
|
let new_dir_path = Path::new(&new_dir);
|
||||||
if new_dir_path.exists() {
|
if new_dir_path.exists() {
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
|
||||||
fs::{self, create_dir_all},
|
fs::{self, create_dir_all},
|
||||||
hash::Hash,
|
path::PathBuf,
|
||||||
path::{Path, PathBuf},
|
|
||||||
sync::{LazyLock, Mutex, RwLockReadGuard, RwLockWriteGuard},
|
sync::{LazyLock, Mutex, RwLockReadGuard, RwLockWriteGuard},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -10,14 +8,12 @@ use chrono::Utc;
|
|||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
use log::{debug, error, info};
|
use log::{debug, error, info};
|
||||||
use rustbreak::{DeSerError, DeSerializer, PathDatabase, RustbreakError};
|
use rustbreak::{DeSerError, DeSerializer, PathDatabase, RustbreakError};
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Serialize};
|
||||||
use serde_with::serde_as;
|
|
||||||
use tauri::AppHandle;
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::DB;
|
use crate::DB;
|
||||||
|
|
||||||
use super::models::data::{Database, GameVersion};
|
use super::models::data::Database;
|
||||||
|
|
||||||
pub static DATA_ROOT_DIR: LazyLock<Mutex<PathBuf>> =
|
pub static DATA_ROOT_DIR: LazyLock<Mutex<PathBuf>> =
|
||||||
LazyLock::new(|| Mutex::new(BaseDirs::new().unwrap().data_dir().join("drop")));
|
LazyLock::new(|| Mutex::new(BaseDirs::new().unwrap().data_dir().join("drop")));
|
||||||
|
|||||||
@@ -162,7 +162,7 @@ pub mod data {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod v2 {
|
pub mod v2 {
|
||||||
use std::{collections::HashMap, io::ErrorKind, path::PathBuf, process::Command};
|
use std::{collections::HashMap, path::PathBuf, process::Command};
|
||||||
|
|
||||||
use crate::process::process_manager::UMU_LAUNCHER_EXECUTABLE;
|
use crate::process::process_manager::UMU_LAUNCHER_EXECUTABLE;
|
||||||
|
|
||||||
|
|||||||
@@ -12,11 +12,13 @@ use std::{
|
|||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::{database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError};
|
use crate::{
|
||||||
|
database::models::data::DownloadableMetadata,
|
||||||
|
error::application_download_error::ApplicationDownloadError,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
download_manager_builder::{CurrentProgressObject, DownloadAgent},
|
download_manager_builder::{CurrentProgressObject, DownloadAgent}, util::queue::Queue,
|
||||||
queue::Queue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub enum DownloadManagerSignal {
|
pub enum DownloadManagerSignal {
|
||||||
|
|||||||
@@ -11,15 +11,14 @@ use log::{debug, error, info, warn};
|
|||||||
use tauri::{AppHandle, Emitter};
|
use tauri::{AppHandle, Emitter};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError, games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent}
|
database::models::data::DownloadableMetadata,
|
||||||
|
error::application_download_error::ApplicationDownloadError,
|
||||||
|
games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
download_manager::{DownloadManager, DownloadManagerSignal, DownloadManagerStatus},
|
download_manager::{DownloadManager, DownloadManagerSignal, DownloadManagerStatus},
|
||||||
download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag},
|
downloadable::Downloadable, util::{download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag}, progress_object::ProgressObject, queue::Queue},
|
||||||
downloadable::Downloadable,
|
|
||||||
progress_object::ProgressObject,
|
|
||||||
queue::Queue,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub type DownloadAgent = Arc<Box<dyn Downloadable + Send + Sync>>;
|
pub type DownloadAgent = Arc<Box<dyn Downloadable + Send + Sync>>;
|
||||||
|
|||||||
@@ -2,11 +2,13 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
|
|
||||||
use crate::{database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError};
|
use crate::{
|
||||||
|
database::models::data::DownloadableMetadata,
|
||||||
|
error::application_download_error::ApplicationDownloadError,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
download_manager::DownloadStatus, download_thread_control_flag::DownloadThreadControl,
|
download_manager::DownloadStatus, util::{download_thread_control_flag::DownloadThreadControl, progress_object::ProgressObject},
|
||||||
progress_object::ProgressObject,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Downloadable: Send + Sync {
|
pub trait Downloadable: Send + Sync {
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
use std::{fmt::Display, io, sync::mpsc::SendError};
|
|
||||||
|
|
||||||
use serde_with::SerializeDisplay;
|
|
||||||
|
|
||||||
#[derive(SerializeDisplay)]
|
|
||||||
pub enum InternalError<T> {
|
|
||||||
IOError(io::Error),
|
|
||||||
SignalError(SendError<T>),
|
|
||||||
}
|
|
||||||
impl<T> Display for InternalError<T> {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
InternalError::IOError(error) => write!(f, "{}", error),
|
|
||||||
InternalError::SignalError(send_error) => write!(f, "{}", send_error),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T> From<SendError<T>> for InternalError<T> {
|
|
||||||
fn from(value: SendError<T>) -> Self {
|
|
||||||
InternalError::SignalError(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
impl<T> From<io::Error> for InternalError<T> {
|
|
||||||
fn from(value: io::Error) -> Self {
|
|
||||||
InternalError::IOError(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,5 @@
|
|||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod download_manager;
|
pub mod download_manager;
|
||||||
pub mod download_manager_builder;
|
pub mod download_manager_builder;
|
||||||
pub mod download_thread_control_flag;
|
|
||||||
pub mod downloadable;
|
pub mod downloadable;
|
||||||
pub mod internal_error;
|
pub mod util;
|
||||||
pub mod progress_object;
|
|
||||||
pub mod queue;
|
|
||||||
pub mod rolling_progress_updates;
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
pub mod progress_object;
|
||||||
|
pub mod queue;
|
||||||
|
pub mod rolling_progress_updates;
|
||||||
|
pub mod download_thread_control_flag;
|
||||||
+3
-1
@@ -10,8 +10,10 @@ use std::{
|
|||||||
use atomic_instant_full::AtomicInstant;
|
use atomic_instant_full::AtomicInstant;
|
||||||
use throttle_my_fn::throttle;
|
use throttle_my_fn::throttle;
|
||||||
|
|
||||||
|
use crate::download_manager::download_manager::DownloadManagerSignal;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
download_manager::DownloadManagerSignal, rolling_progress_updates::RollingProgressWindow,
|
rolling_progress_updates::RollingProgressWindow,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
use std::{fmt::Display, io, sync::mpsc::SendError};
|
||||||
|
|
||||||
|
use serde_with::SerializeDisplay;
|
||||||
|
|
||||||
|
#[derive(SerializeDisplay)]
|
||||||
|
pub enum DownloadManagerError<T> {
|
||||||
|
IOError(io::Error),
|
||||||
|
SignalError(SendError<T>),
|
||||||
|
}
|
||||||
|
impl<T> Display for DownloadManagerError<T> {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
DownloadManagerError::IOError(error) => write!(f, "{}", error),
|
||||||
|
DownloadManagerError::SignalError(send_error) => write!(f, "{}", send_error),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<T> From<SendError<T>> for DownloadManagerError<T> {
|
||||||
|
fn from(value: SendError<T>) -> Self {
|
||||||
|
DownloadManagerError::SignalError(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl<T> From<io::Error> for DownloadManagerError<T> {
|
||||||
|
fn from(value: io::Error) -> Self {
|
||||||
|
DownloadManagerError::IOError(value)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
pub mod application_download_error;
|
pub mod application_download_error;
|
||||||
pub mod drop_server_error;
|
pub mod drop_server_error;
|
||||||
|
pub mod download_manager_error;
|
||||||
pub mod library_error;
|
pub mod library_error;
|
||||||
pub mod process_error;
|
pub mod process_error;
|
||||||
pub mod remote_access_error;
|
pub mod remote_access_error;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use std::{
|
use std::{
|
||||||
any::{Any, TypeId},
|
|
||||||
error::Error,
|
error::Error,
|
||||||
fmt::{Display, Formatter},
|
fmt::{Display, Formatter},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@@ -23,7 +22,6 @@ pub enum RemoteAccessError {
|
|||||||
ManifestDownloadFailed(StatusCode, String),
|
ManifestDownloadFailed(StatusCode, String),
|
||||||
OutOfSync,
|
OutOfSync,
|
||||||
Cache(cacache::Error),
|
Cache(cacache::Error),
|
||||||
Generic(String),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for RemoteAccessError {
|
impl Display for RemoteAccessError {
|
||||||
@@ -59,7 +57,6 @@ impl Display for RemoteAccessError {
|
|||||||
status, response
|
status, response
|
||||||
),
|
),
|
||||||
RemoteAccessError::OutOfSync => write!(f, "server's and client's time are out of sync. Please ensure they are within at least 30 seconds of each other"),
|
RemoteAccessError::OutOfSync => write!(f, "server's and client's time are out of sync. Please ensure they are within at least 30 seconds of each other"),
|
||||||
RemoteAccessError::Generic(message) => write!(f, "{}", message),
|
|
||||||
RemoteAccessError::Cache(error) => write!(f, "Cache Error: {}", error),
|
RemoteAccessError::Cache(error) => write!(f, "Cache Error: {}", error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ pub struct Collection {
|
|||||||
name: String,
|
name: String,
|
||||||
is_default: bool,
|
is_default: bool,
|
||||||
user_id: String,
|
user_id: String,
|
||||||
entries: Vec<CollectionObject>
|
entries: Vec<CollectionObject>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
|
||||||
@@ -21,4 +21,3 @@ pub struct CollectionObject {
|
|||||||
game_id: String,
|
game_id: String,
|
||||||
game: Game,
|
game: Game,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,12 @@ use reqwest::blocking::Client;
|
|||||||
use serde_json::json;
|
use serde_json::json;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{database::db::DatabaseImpls, error::remote_access_error::RemoteAccessError, remote::{auth::generate_authorization_header, requests::make_request}, DB};
|
use crate::{
|
||||||
|
database::db::DatabaseImpls,
|
||||||
|
error::remote_access_error::RemoteAccessError,
|
||||||
|
remote::{auth::generate_authorization_header, requests::make_request},
|
||||||
|
DB,
|
||||||
|
};
|
||||||
|
|
||||||
use super::collection::{Collection, Collections};
|
use super::collection::{Collection, Collections};
|
||||||
|
|
||||||
@@ -20,9 +25,12 @@ pub fn fetch_collections() -> Result<Collections, RemoteAccessError> {
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn fetch_collection(collection_id: String) -> Result<Collection, RemoteAccessError> {
|
pub fn fetch_collection(collection_id: String) -> Result<Collection, RemoteAccessError> {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
let response = make_request(&client, &["/api/v1/client/collection/", &collection_id], &[], |r| {
|
let response = make_request(
|
||||||
r.header("Authorization", generate_authorization_header())
|
&client,
|
||||||
})?
|
&["/api/v1/client/collection/", &collection_id],
|
||||||
|
&[],
|
||||||
|
|r| r.header("Authorization", generate_authorization_header()),
|
||||||
|
)?
|
||||||
.send()?;
|
.send()?;
|
||||||
|
|
||||||
Ok(response.json()?)
|
Ok(response.json()?)
|
||||||
@@ -35,7 +43,6 @@ pub fn create_collection(name: String) -> Result<Collection, RemoteAccessError>
|
|||||||
|
|
||||||
let base_url = Url::parse(&format!("{}api/v1/client/collection/", base_url))?;
|
let base_url = Url::parse(&format!("{}api/v1/client/collection/", base_url))?;
|
||||||
|
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.post(base_url)
|
.post(base_url)
|
||||||
.header("Authorization", generate_authorization_header())
|
.header("Authorization", generate_authorization_header())
|
||||||
@@ -46,9 +53,16 @@ pub fn create_collection(name: String) -> Result<Collection, RemoteAccessError>
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn add_game_to_collection(collection_id: String, game_id: String) -> Result<(), RemoteAccessError> {
|
pub fn add_game_to_collection(
|
||||||
|
collection_id: String,
|
||||||
|
game_id: String,
|
||||||
|
) -> Result<(), RemoteAccessError> {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
let url = Url::parse(&format!("{}api/v1/client/collection/{}/entry/", DB.fetch_base_url(), collection_id))?;
|
let url = Url::parse(&format!(
|
||||||
|
"{}api/v1/client/collection/{}/entry/",
|
||||||
|
DB.fetch_base_url(),
|
||||||
|
collection_id
|
||||||
|
))?;
|
||||||
|
|
||||||
client
|
client
|
||||||
.post(url)
|
.post(url)
|
||||||
@@ -61,7 +75,11 @@ pub fn add_game_to_collection(collection_id: String, game_id: String) -> Result<
|
|||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn delete_collection(collection_id: String) -> Result<bool, RemoteAccessError> {
|
pub fn delete_collection(collection_id: String) -> Result<bool, RemoteAccessError> {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
let base_url = Url::parse(&format!("{}api/v1/client/collection/{}", DB.fetch_base_url(), collection_id))?;
|
let base_url = Url::parse(&format!(
|
||||||
|
"{}api/v1/client/collection/{}",
|
||||||
|
DB.fetch_base_url(),
|
||||||
|
collection_id
|
||||||
|
))?;
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.delete(base_url)
|
.delete(base_url)
|
||||||
@@ -71,9 +89,16 @@ pub fn delete_collection(collection_id: String) -> Result<bool, RemoteAccessErro
|
|||||||
Ok(response.json()?)
|
Ok(response.json()?)
|
||||||
}
|
}
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn delete_game_in_collection(collection_id: String, game_id: String) -> Result<(), RemoteAccessError> {
|
pub fn delete_game_in_collection(
|
||||||
|
collection_id: String,
|
||||||
|
game_id: String,
|
||||||
|
) -> Result<(), RemoteAccessError> {
|
||||||
let client = Client::new();
|
let client = Client::new();
|
||||||
let base_url = Url::parse(&format!("{}api/v1/client/collection/{}/entry", DB.fetch_base_url(), collection_id))?;
|
let base_url = Url::parse(&format!(
|
||||||
|
"{}api/v1/client/collection/{}/entry",
|
||||||
|
DB.fetch_base_url(),
|
||||||
|
collection_id
|
||||||
|
))?;
|
||||||
|
|
||||||
client
|
client
|
||||||
.delete(base_url)
|
.delete(base_url)
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
pub mod commands;
|
|
||||||
pub mod collection;
|
pub mod collection;
|
||||||
|
pub mod commands;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::AppHandle;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::models::data::GameVersion,
|
database::models::data::GameVersion,
|
||||||
|
|||||||
@@ -3,9 +3,7 @@ use std::sync::{Arc, Mutex};
|
|||||||
use crate::{
|
use crate::{
|
||||||
download_manager::{
|
download_manager::{
|
||||||
download_manager::DownloadManagerSignal, downloadable::Downloadable,
|
download_manager::DownloadManagerSignal, downloadable::Downloadable,
|
||||||
internal_error::InternalError,
|
}, error::download_manager_error::DownloadManagerError, AppState
|
||||||
},
|
|
||||||
AppState,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::download_agent::GameDownloadAgent;
|
use super::download_agent::GameDownloadAgent;
|
||||||
@@ -16,7 +14,7 @@ pub fn download_game(
|
|||||||
game_version: String,
|
game_version: String,
|
||||||
install_dir: usize,
|
install_dir: usize,
|
||||||
state: tauri::State<'_, Mutex<AppState>>,
|
state: tauri::State<'_, Mutex<AppState>>,
|
||||||
) -> Result<(), InternalError<DownloadManagerSignal>> {
|
) -> Result<(), DownloadManagerError<DownloadManagerSignal>> {
|
||||||
let sender = state.lock().unwrap().download_manager.get_sender();
|
let sender = state.lock().unwrap().download_manager.get_sender();
|
||||||
let game_download_agent = Arc::new(Box::new(GameDownloadAgent::new(
|
let game_download_agent = Arc::new(Box::new(GameDownloadAgent::new(
|
||||||
game_id,
|
game_id,
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
use crate::auth::generate_authorization_header;
|
use crate::auth::generate_authorization_header;
|
||||||
use crate::database::db::borrow_db_checked;
|
use crate::database::db::borrow_db_checked;
|
||||||
use crate::database::models::data::{ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus};
|
use crate::database::models::data::{
|
||||||
use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus};
|
ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus,
|
||||||
use crate::download_manager::download_thread_control_flag::{
|
|
||||||
DownloadThreadControl, DownloadThreadControlFlag,
|
|
||||||
};
|
};
|
||||||
|
use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus};
|
||||||
use crate::download_manager::downloadable::Downloadable;
|
use crate::download_manager::downloadable::Downloadable;
|
||||||
use crate::download_manager::progress_object::{ProgressHandle, ProgressObject};
|
use crate::download_manager::util::download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag};
|
||||||
|
use crate::download_manager::util::progress_object::{ProgressHandle, ProgressObject};
|
||||||
use crate::error::application_download_error::ApplicationDownloadError;
|
use crate::error::application_download_error::ApplicationDownloadError;
|
||||||
use crate::error::remote_access_error::RemoteAccessError;
|
use crate::error::remote_access_error::RemoteAccessError;
|
||||||
use crate::games::downloads::manifest::{DropDownloadContext, DropManifest};
|
use crate::games::downloads::manifest::{DropDownloadContext, DropManifest};
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
use crate::download_manager::download_thread_control_flag::{
|
use crate::download_manager::util::download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag};
|
||||||
DownloadThreadControl, DownloadThreadControlFlag,
|
use crate::download_manager::util::progress_object::ProgressHandle;
|
||||||
};
|
|
||||||
use crate::download_manager::progress_object::ProgressHandle;
|
|
||||||
use crate::error::application_download_error::ApplicationDownloadError;
|
use crate::error::application_download_error::ApplicationDownloadError;
|
||||||
use crate::error::remote_access_error::RemoteAccessError;
|
use crate::error::remote_access_error::RemoteAccessError;
|
||||||
use crate::games::downloads::manifest::DropDownloadContext;
|
use crate::games::downloads::manifest::DropDownloadContext;
|
||||||
|
|||||||
@@ -2,13 +2,15 @@ use std::fs::remove_dir_all;
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::thread::spawn;
|
use std::thread::spawn;
|
||||||
|
|
||||||
use log::{debug, error, info, warn};
|
use log::{debug, error, warn};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tauri::Emitter;
|
use tauri::Emitter;
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::AppHandle;
|
||||||
|
|
||||||
use crate::database::db::{borrow_db_checked, borrow_db_mut_checked, save_db};
|
use crate::database::db::{borrow_db_checked, borrow_db_mut_checked, save_db};
|
||||||
use crate::database::models::data::{ApplicationTransientStatus, DownloadableMetadata, GameDownloadStatus, GameVersion};
|
use crate::database::models::data::{
|
||||||
|
ApplicationTransientStatus, DownloadableMetadata, GameDownloadStatus, GameVersion,
|
||||||
|
};
|
||||||
use crate::download_manager::download_manager::DownloadStatus;
|
use crate::download_manager::download_manager::DownloadStatus;
|
||||||
use crate::error::library_error::LibraryError;
|
use crate::error::library_error::LibraryError;
|
||||||
use crate::error::remote_access_error::RemoteAccessError;
|
use crate::error::remote_access_error::RemoteAccessError;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
pub mod collections;
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod downloads;
|
pub mod downloads;
|
||||||
pub mod library;
|
pub mod library;
|
||||||
pub mod state;
|
pub mod state;
|
||||||
pub mod collections;
|
|
||||||
@@ -1,4 +1,7 @@
|
|||||||
use crate::database::{db::borrow_db_checked, models::data::{ApplicationTransientStatus, GameDownloadStatus}};
|
use crate::database::{
|
||||||
|
db::borrow_db_checked,
|
||||||
|
models::data::{ApplicationTransientStatus, GameDownloadStatus},
|
||||||
|
};
|
||||||
|
|
||||||
pub type GameStatusWithTransient = (
|
pub type GameStatusWithTransient = (
|
||||||
Option<GameDownloadStatus>,
|
Option<GameDownloadStatus>,
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
mod database;
|
mod database;
|
||||||
mod games;
|
mod games;
|
||||||
|
|
||||||
mod autostart;
|
mod client;
|
||||||
mod cleanup;
|
|
||||||
mod commands;
|
|
||||||
mod download_manager;
|
mod download_manager;
|
||||||
mod error;
|
mod error;
|
||||||
mod process;
|
mod process;
|
||||||
mod remote;
|
mod remote;
|
||||||
|
|
||||||
use crate::database::db::DatabaseImpls;
|
use crate::database::db::DatabaseImpls;
|
||||||
use autostart::{get_autostart_enabled, toggle_autostart};
|
use client::{
|
||||||
use cleanup::{cleanup_and_exit, quit};
|
autostart::{get_autostart_enabled, sync_autostart_on_startup, toggle_autostart},
|
||||||
use commands::fetch_state;
|
cleanup::{cleanup_and_exit, quit},
|
||||||
|
};
|
||||||
|
use client::commands::fetch_state;
|
||||||
use database::commands::{
|
use database::commands::{
|
||||||
add_download_dir, delete_download_dir, fetch_download_dir_stats, fetch_settings,
|
add_download_dir, delete_download_dir, fetch_download_dir_stats, fetch_settings,
|
||||||
fetch_system_data, update_settings,
|
fetch_system_data, update_settings,
|
||||||
@@ -33,7 +33,6 @@ use games::commands::{
|
|||||||
};
|
};
|
||||||
use games::downloads::commands::download_game;
|
use games::downloads::commands::download_game;
|
||||||
use games::library::{update_game_configuration, Game};
|
use games::library::{update_game_configuration, Game};
|
||||||
use http::Response;
|
|
||||||
use log::{debug, info, warn, LevelFilter};
|
use log::{debug, info, warn, LevelFilter};
|
||||||
use log4rs::append::console::ConsoleAppender;
|
use log4rs::append::console::ConsoleAppender;
|
||||||
use log4rs::append::file::FileAppender;
|
use log4rs::append::file::FileAppender;
|
||||||
@@ -48,9 +47,7 @@ use remote::commands::{
|
|||||||
sign_out, use_remote,
|
sign_out, use_remote,
|
||||||
};
|
};
|
||||||
use remote::fetch_object::{fetch_object, fetch_object_offline};
|
use remote::fetch_object::{fetch_object, fetch_object_offline};
|
||||||
use remote::requests::make_request;
|
|
||||||
use remote::server_proto::{handle_server_proto, handle_server_proto_offline};
|
use remote::server_proto::{handle_server_proto, handle_server_proto_offline};
|
||||||
use reqwest::blocking::Body;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
@@ -196,7 +193,7 @@ fn setup(handle: AppHandle) -> AppState<'static> {
|
|||||||
debug!("finished setup!");
|
debug!("finished setup!");
|
||||||
|
|
||||||
// Sync autostart state
|
// Sync autostart state
|
||||||
if let Err(e) = autostart::sync_autostart_on_startup(&handle) {
|
if let Err(e) = sync_autostart_on_startup(&handle) {
|
||||||
warn!("failed to sync autostart state: {}", e);
|
warn!("failed to sync autostart state: {}", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fs::{File, OpenOptions},
|
fs::OpenOptions,
|
||||||
io::{self, Error},
|
io::{self},
|
||||||
path::{Path, PathBuf},
|
path::PathBuf,
|
||||||
process::{Child, Command, ExitStatus},
|
process::{Command, ExitStatus},
|
||||||
str::FromStr,
|
str::FromStr,
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
thread::spawn,
|
thread::spawn,
|
||||||
@@ -15,12 +15,14 @@ use log::{debug, info, warn};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use shared_child::SharedChild;
|
use shared_child::SharedChild;
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
use umu_wrapper_lib::command_builder::UmuCommandBuilder;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{
|
database::{
|
||||||
db::{borrow_db_mut_checked, DATA_ROOT_DIR},
|
db::{borrow_db_mut_checked, DATA_ROOT_DIR},
|
||||||
models::data::{ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus, GameVersion},
|
models::data::{
|
||||||
|
ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus,
|
||||||
|
GameVersion,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
error::process_error::ProcessError,
|
error::process_error::ProcessError,
|
||||||
games::{library::push_game_update, state::GameStatusManager},
|
games::{library::push_game_update, state::GameStatusManager},
|
||||||
@@ -46,7 +48,7 @@ impl ProcessManager<'_> {
|
|||||||
current_platform: Platform::Windows,
|
current_platform: Platform::Windows,
|
||||||
|
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
current_platform: Platform::macOS,
|
current_platform: Platform::MacOs,
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
current_platform: Platform::Linux,
|
current_platform: Platform::Linux,
|
||||||
@@ -65,7 +67,7 @@ impl ProcessManager<'_> {
|
|||||||
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
(Platform::macOS, Platform::macOS),
|
(Platform::MacOs, Platform::MacOs),
|
||||||
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
&NativeGameLauncher {} as &(dyn ProcessHandler + Sync + Send + 'static),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
@@ -330,7 +332,7 @@ impl ProcessManager<'_> {
|
|||||||
pub enum Platform {
|
pub enum Platform {
|
||||||
Windows,
|
Windows,
|
||||||
Linux,
|
Linux,
|
||||||
macOS,
|
MacOs,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ProcessHandler: Send + 'static {
|
pub trait ProcessHandler: Send + 'static {
|
||||||
@@ -351,8 +353,8 @@ impl ProcessHandler for NativeGameLauncher {
|
|||||||
_meta: &DownloadableMetadata,
|
_meta: &DownloadableMetadata,
|
||||||
launch_command: String,
|
launch_command: String,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
game_version: &GameVersion,
|
_game_version: &GameVersion,
|
||||||
current_dir: &str,
|
_current_dir: &str,
|
||||||
) -> String {
|
) -> String {
|
||||||
format!("\"{}\" {}", launch_command, args.join(" "))
|
format!("\"{}\" {}", launch_command, args.join(" "))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,20 @@
|
|||||||
use std::{collections::HashMap, env, sync::Mutex};
|
use std::{collections::HashMap, env};
|
||||||
|
|
||||||
use chrono::Utc;
|
use chrono::Utc;
|
||||||
use droplet_rs::ssl::sign_nonce;
|
use droplet_rs::ssl::sign_nonce;
|
||||||
use gethostname::gethostname;
|
use gethostname::gethostname;
|
||||||
use log::{debug, error, warn};
|
use log::{debug, error, warn};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json::json;
|
use tauri::{AppHandle, Emitter};
|
||||||
use tauri::{AppHandle, Emitter, Manager};
|
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{
|
database::{
|
||||||
db::{borrow_db_checked, borrow_db_mut_checked, save_db, DatabaseImpls},
|
db::{borrow_db_checked, borrow_db_mut_checked, save_db},
|
||||||
models::data::DatabaseAuth,
|
models::data::DatabaseAuth,
|
||||||
},
|
},
|
||||||
error::{drop_server_error::DropServerError, remote_access_error::RemoteAccessError},
|
error::{drop_server_error::DropServerError, remote_access_error::RemoteAccessError},
|
||||||
AppState, AppStatus, User, DB,
|
AppStatus, User,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
use std::sync::RwLockReadGuard;
|
use crate::{
|
||||||
|
database::{db::borrow_db_checked, models::data::Database},
|
||||||
use crate::{database::{db::borrow_db_checked, models::data::Database}, error::remote_access_error::RemoteAccessError};
|
error::remote_access_error::RemoteAccessError,
|
||||||
|
};
|
||||||
use cacache::Integrity;
|
use cacache::Integrity;
|
||||||
use http::{header::CONTENT_TYPE, response::Builder as ResponseBuilder, Response};
|
use http::{header::CONTENT_TYPE, response::Builder as ResponseBuilder, Response};
|
||||||
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||||
|
|||||||
@@ -6,11 +6,16 @@ use tauri::{AppHandle, Emitter, Manager};
|
|||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::db::{borrow_db_checked, borrow_db_mut_checked, save_db}, error::remote_access_error::RemoteAccessError, remote::{auth::generate_authorization_header, requests::make_request}, AppState, AppStatus
|
database::db::{borrow_db_checked, borrow_db_mut_checked, save_db},
|
||||||
|
error::remote_access_error::RemoteAccessError,
|
||||||
|
remote::{auth::generate_authorization_header, requests::make_request},
|
||||||
|
AppState, AppStatus,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
auth::{auth_initiate_logic, recieve_handshake, setup}, cache::{cache_object, get_cached_object}, remote::use_remote_logic
|
auth::{auth_initiate_logic, recieve_handshake, setup},
|
||||||
|
cache::{cache_object, get_cached_object},
|
||||||
|
remote::use_remote_logic,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
@@ -36,24 +41,22 @@ pub fn gen_drop_url(path: String) -> Result<String, RemoteAccessError> {
|
|||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn fetch_drop_object(path: String) -> Result<Vec<u8>, RemoteAccessError> {
|
pub fn fetch_drop_object(path: String) -> Result<Vec<u8>, RemoteAccessError> {
|
||||||
let drop_url = gen_drop_url(path.clone());
|
let _drop_url = gen_drop_url(path.clone())?;
|
||||||
let req = make_request(
|
let req = make_request(&Client::new(), &[&path], &[], |r| {
|
||||||
&Client::new(),
|
r.header("Authorization", generate_authorization_header())
|
||||||
&[&path],
|
})?
|
||||||
&[],
|
.send();
|
||||||
|r| { r.header("Authorization", generate_authorization_header()) }
|
|
||||||
)?.send();
|
|
||||||
|
|
||||||
match req {
|
match req {
|
||||||
Ok(data) => {
|
Ok(data) => {
|
||||||
let data = data.bytes()?.to_vec();
|
let data = data.bytes()?.to_vec();
|
||||||
cache_object(&path, &data)?;
|
cache_object(&path, &data)?;
|
||||||
Ok(data)
|
Ok(data)
|
||||||
},
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
debug!("{}", e);
|
debug!("{}", e);
|
||||||
get_cached_object::<&str, Vec<u8>>(&path)
|
get_cached_object::<&str, Vec<u8>>(&path)
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@@ -2,12 +2,13 @@ use http::{header::CONTENT_TYPE, response::Builder as ResponseBuilder};
|
|||||||
use log::warn;
|
use log::warn;
|
||||||
use tauri::UriSchemeResponder;
|
use tauri::UriSchemeResponder;
|
||||||
|
|
||||||
use super::{auth::generate_authorization_header, cache::{cache_object, get_cached_object, ObjectCache}, requests::make_request};
|
use super::{
|
||||||
|
auth::generate_authorization_header,
|
||||||
|
cache::{cache_object, get_cached_object, ObjectCache},
|
||||||
|
requests::make_request,
|
||||||
|
};
|
||||||
|
|
||||||
pub fn fetch_object(
|
pub fn fetch_object(request: http::Request<Vec<u8>>, responder: UriSchemeResponder) {
|
||||||
request: http::Request<Vec<u8>>,
|
|
||||||
responder: UriSchemeResponder,
|
|
||||||
) {
|
|
||||||
// Drop leading /
|
// Drop leading /
|
||||||
let object_id = &request.uri().path()[1..];
|
let object_id = &request.uri().path()[1..];
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ pub fn fetch_object(
|
|||||||
Ok(data) => responder.respond(data.into()),
|
Ok(data) => responder.respond(data.into()),
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
warn!("{}", e)
|
warn!("{}", e)
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -41,10 +42,7 @@ pub fn fetch_object(
|
|||||||
|
|
||||||
responder.respond(resp);
|
responder.respond(resp);
|
||||||
}
|
}
|
||||||
pub fn fetch_object_offline(
|
pub fn fetch_object_offline(request: http::Request<Vec<u8>>, responder: UriSchemeResponder) {
|
||||||
request: http::Request<Vec<u8>>,
|
|
||||||
responder: UriSchemeResponder,
|
|
||||||
) {
|
|
||||||
let object_id = &request.uri().path()[1..];
|
let object_id = &request.uri().path()[1..];
|
||||||
let data = get_cached_object::<&str, ObjectCache>(object_id);
|
let data = get_cached_object::<&str, ObjectCache>(object_id);
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
use std::{path::PathBuf, str::FromStr};
|
use std::str::FromStr;
|
||||||
|
|
||||||
use http::{
|
use http::{
|
||||||
uri::{Authority, PathAndQuery},
|
uri::PathAndQuery,
|
||||||
Request, Response, StatusCode, Uri,
|
Request, Response, StatusCode, Uri,
|
||||||
};
|
};
|
||||||
use log::info;
|
|
||||||
use reqwest::blocking::Client;
|
use reqwest::blocking::Client;
|
||||||
use tauri::UriSchemeResponder;
|
use tauri::UriSchemeResponder;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
/* automatically generated by rust-bindgen 0.71.1 */
|
/* automatically generated by rust-bindgen 0.71.1 */
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
|
#[derive(PartialEq, Copy, Clone, Hash, Debug, Default)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct __BindgenComplex<T> {
|
pub struct __BindgenComplex<T> {
|
||||||
|
|||||||
Reference in New Issue
Block a user