mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-13 16:22:43 +10:00
feat: move to native_model to allow for database upgrades
This commit is contained in:
@ -87,7 +87,7 @@ router.afterEach(() => {
|
|||||||
|
|
||||||
const state = useAppState();
|
const state = useAppState();
|
||||||
const profilePictureUrl: string = await useObject(
|
const profilePictureUrl: string = await useObject(
|
||||||
state.value.user?.profilePicture ?? ""
|
state.value.user?.profilePictureObjectId ?? ""
|
||||||
);
|
);
|
||||||
const adminUrl: string = await invoke("gen_drop_url", {
|
const adminUrl: string = await invoke("gen_drop_url", {
|
||||||
path: "/admin",
|
path: "/admin",
|
||||||
|
|||||||
163
src-tauri/Cargo.lock
generated
163
src-tauri/Cargo.lock
generated
@ -605,12 +605,6 @@ version = "0.3.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
checksum = "e3b5ca7a04898ad4bcd41c90c5285445ff5b791899bb1b0abdd2a2aa791211d7"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "bytecount"
|
|
||||||
version = "0.6.8"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "5ce89b21cab1437276d2650d57e971f9d548a2d9037cc231abdc0562b97498ce"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytemuck"
|
name = "bytemuck"
|
||||||
version = "1.21.0"
|
version = "1.21.0"
|
||||||
@ -724,19 +718,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "cargo_metadata"
|
|
||||||
version = "0.14.2"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4acbb09d9ee8e23699b9634375c72795d095bf268439da88562cf9b501f181fa"
|
|
||||||
dependencies = [
|
|
||||||
"camino",
|
|
||||||
"cargo-platform",
|
|
||||||
"semver",
|
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo_metadata"
|
name = "cargo_metadata"
|
||||||
version = "0.18.1"
|
version = "0.18.1"
|
||||||
@ -1355,7 +1336,6 @@ name = "drop-app"
|
|||||||
version = "0.3.0-rc-1"
|
version = "0.3.0-rc-1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atomic-instant-full",
|
"atomic-instant-full",
|
||||||
"bincode",
|
|
||||||
"boxcar",
|
"boxcar",
|
||||||
"cacache 13.1.0",
|
"cacache 13.1.0",
|
||||||
"chrono",
|
"chrono",
|
||||||
@ -1370,8 +1350,7 @@ dependencies = [
|
|||||||
"log",
|
"log",
|
||||||
"log4rs",
|
"log4rs",
|
||||||
"md5",
|
"md5",
|
||||||
"native_db",
|
"native_model",
|
||||||
"native_model 0.6.1",
|
|
||||||
"parking_lot 0.12.3",
|
"parking_lot 0.12.3",
|
||||||
"rayon",
|
"rayon",
|
||||||
"reqwest 0.12.9",
|
"reqwest 0.12.9",
|
||||||
@ -1556,15 +1535,6 @@ dependencies = [
|
|||||||
"windows-sys 0.59.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "error-chain"
|
|
||||||
version = "0.12.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2d2f06b9cac1506ece98fe3231e3cc9c4410ec3d5b1f24ae1c8946f0742cdefc"
|
|
||||||
dependencies = [
|
|
||||||
"version_check",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "event-listener"
|
name = "event-listener"
|
||||||
version = "2.5.3"
|
version = "2.5.3"
|
||||||
@ -3148,48 +3118,6 @@ dependencies = [
|
|||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "native_db"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "db7c6b50f9889052a3c1bbd3aa70cc33b76ec1761092aeb0ec0e1ac3cfdb881a"
|
|
||||||
dependencies = [
|
|
||||||
"native_db_macro",
|
|
||||||
"native_model 0.4.20",
|
|
||||||
"redb 1.5.1",
|
|
||||||
"redb 2.5.0",
|
|
||||||
"semver",
|
|
||||||
"serde",
|
|
||||||
"skeptic",
|
|
||||||
"thiserror 1.0.69",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "native_db_macro"
|
|
||||||
version = "0.8.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "434acde56fc4485e0b62533bb2fbc08155ee7e47408b1358348acff556c31b3c"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.91",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "native_model"
|
|
||||||
version = "0.4.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c10f4542302b7fa69ef18b49d93106e27f20b59d695555121d9ed22fe5d716a8"
|
|
||||||
dependencies = [
|
|
||||||
"anyhow",
|
|
||||||
"bincode",
|
|
||||||
"native_model_macro 0.4.20",
|
|
||||||
"serde",
|
|
||||||
"skeptic",
|
|
||||||
"thiserror 1.0.69",
|
|
||||||
"zerocopy 0.8.25",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "native_model"
|
name = "native_model"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
@ -3199,23 +3127,13 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"bincode",
|
"bincode",
|
||||||
"doc-comment",
|
"doc-comment",
|
||||||
"native_model_macro 0.6.1",
|
"native_model_macro",
|
||||||
|
"rmp-serde",
|
||||||
"serde",
|
"serde",
|
||||||
"thiserror 2.0.9",
|
"thiserror 2.0.9",
|
||||||
"zerocopy 0.8.25",
|
"zerocopy 0.8.25",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "native_model_macro"
|
|
||||||
version = "0.4.20"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "2f385f3d57adaea8d8868e65a0bc821bcb8ba2228bbf87a1c3c6144ac48f3791"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 2.0.91",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "native_model_macro"
|
name = "native_model_macro"
|
||||||
version = "0.6.1"
|
version = "0.6.1"
|
||||||
@ -3809,6 +3727,12 @@ dependencies = [
|
|||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "paste"
|
||||||
|
version = "1.0.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pathdiff"
|
name = "pathdiff"
|
||||||
version = "0.2.3"
|
version = "0.2.3"
|
||||||
@ -4125,17 +4049,6 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "pulldown-cmark"
|
|
||||||
version = "0.9.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "57206b407293d2bcd3af849ce869d52068623f19e1b5ff8e8778e3309439682b"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.6.0",
|
|
||||||
"memchr",
|
|
||||||
"unicase",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "quick-xml"
|
name = "quick-xml"
|
||||||
version = "0.32.0"
|
version = "0.32.0"
|
||||||
@ -4284,24 +4197,6 @@ dependencies = [
|
|||||||
"yasna",
|
"yasna",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redb"
|
|
||||||
version = "1.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "fd7f82ecd6ba647a39dd1a7172b8a1cd9453c0adee6da20cb553d83a9a460fa5"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "redb"
|
|
||||||
version = "2.5.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "34bc6763177194266fc3773e2b2bb3693f7b02fdf461e285aa33202e3164b74e"
|
|
||||||
dependencies = [
|
|
||||||
"libc",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
@ -4543,6 +4438,28 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rmp"
|
||||||
|
version = "0.8.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "228ed7c16fa39782c3b3468e974aec2795e9089153cd08ee2e9aefb3613334c4"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"num-traits",
|
||||||
|
"paste",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rmp-serde"
|
||||||
|
version = "1.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "52e599a477cf9840e92f2cde9a7189e67b42c57532749bf90aea6ec10facd4db"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"rmp",
|
||||||
|
"serde",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-ini"
|
name = "rust-ini"
|
||||||
version = "0.21.1"
|
version = "0.21.1"
|
||||||
@ -4560,6 +4477,7 @@ version = "2.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "460d97902465327d69ecfe8cefdb5972c6f94d6127ac9e992acdb51458bebc27"
|
checksum = "460d97902465327d69ecfe8cefdb5972c6f94d6127ac9e992acdb51458bebc27"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
"serde",
|
"serde",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
@ -5077,21 +4995,6 @@ version = "0.3.11"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
|
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "skeptic"
|
|
||||||
version = "0.13.7"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "16d23b015676c90a0f01c197bfdc786c20342c73a0afdda9025adb0bc42940a8"
|
|
||||||
dependencies = [
|
|
||||||
"bytecount",
|
|
||||||
"cargo_metadata 0.14.2",
|
|
||||||
"error-chain",
|
|
||||||
"glob",
|
|
||||||
"pulldown-cmark",
|
|
||||||
"tempfile",
|
|
||||||
"walkdir",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "slab"
|
name = "slab"
|
||||||
version = "0.4.9"
|
version = "0.4.9"
|
||||||
@ -5766,7 +5669,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "9271a88f99b4adea0dc71d0baca4505475a0bbd139fb135f62958721aaa8fe54"
|
checksum = "9271a88f99b4adea0dc71d0baca4505475a0bbd139fb135f62958721aaa8fe54"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"brotli",
|
"brotli",
|
||||||
"cargo_metadata 0.18.1",
|
"cargo_metadata",
|
||||||
"ctor",
|
"ctor",
|
||||||
"dunce",
|
"dunce",
|
||||||
"glob",
|
"glob",
|
||||||
|
|||||||
@ -16,8 +16,6 @@ tauri-plugin-single-instance = { version = "2.0.0", features = ["deep-link"] }
|
|||||||
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
# This seems to be only an issue on Windows, see https://github.com/rust-lang/cargo/issues/8519
|
||||||
name = "drop_app_lib"
|
name = "drop_app_lib"
|
||||||
crate-type = ["staticlib", "cdylib", "rlib"]
|
crate-type = ["staticlib", "cdylib", "rlib"]
|
||||||
|
|
||||||
[build]
|
|
||||||
rustflags = ["-C", "target-feature=+aes,+sse2"]
|
rustflags = ["-C", "target-feature=+aes,+sse2"]
|
||||||
|
|
||||||
|
|
||||||
@ -51,15 +49,13 @@ throttle_my_fn = "0.2.6"
|
|||||||
parking_lot = "0.12.3"
|
parking_lot = "0.12.3"
|
||||||
atomic-instant-full = "0.1.0"
|
atomic-instant-full = "0.1.0"
|
||||||
cacache = "13.1.0"
|
cacache = "13.1.0"
|
||||||
bincode = "1.3.3"
|
|
||||||
http-serde = "2.1.1"
|
http-serde = "2.1.1"
|
||||||
reqwest-middleware = "0.4.0"
|
reqwest-middleware = "0.4.0"
|
||||||
reqwest-middleware-cache = "0.1.1"
|
reqwest-middleware-cache = "0.1.1"
|
||||||
deranged = "=0.4.0"
|
deranged = "=0.4.0"
|
||||||
droplet-rs = "0.7.3"
|
droplet-rs = "0.7.3"
|
||||||
gethostname = "1.0.1"
|
gethostname = "1.0.1"
|
||||||
native_db = "0.8.1"
|
native_model = { version = "0.6.1", features = ["rmp_serde_1_3"] }
|
||||||
native_model = "0.6.1"
|
|
||||||
tailscale = { path = "./tailscale" }
|
tailscale = { path = "./tailscale" }
|
||||||
|
|
||||||
[dependencies.dynfmt]
|
[dependencies.dynfmt]
|
||||||
@ -92,7 +88,7 @@ features = [
|
|||||||
|
|
||||||
[dependencies.rustbreak]
|
[dependencies.rustbreak]
|
||||||
version = "2"
|
version = "2"
|
||||||
features = [] # You can also use "yaml_enc" or "bin_enc"
|
features = ["other_errors"] # You can also use "yaml_enc" or "bin_enc"
|
||||||
|
|
||||||
[dependencies.reqwest]
|
[dependencies.reqwest]
|
||||||
version = "0.12"
|
version = "0.12"
|
||||||
|
|||||||
@ -7,13 +7,13 @@ use std::{
|
|||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::{db::borrow_db_mut_checked, settings::Settings},
|
database::{db::borrow_db_mut_checked},
|
||||||
download_manager::internal_error::InternalError,
|
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,
|
debug::SystemData, models::data::Settings,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Will, in future, return disk/remaining size
|
// Will, in future, return disk/remaining size
|
||||||
|
|||||||
@ -15,122 +15,10 @@ use serde_with::serde_as;
|
|||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::DB;
|
||||||
database::settings::Settings,
|
|
||||||
download_manager::downloadable_metadata::DownloadableMetadata,
|
|
||||||
games::{library::push_game_update, state::GameStatusManager},
|
|
||||||
process::process_manager::Platform,
|
|
||||||
DB,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(serde::Serialize, Clone, Deserialize)]
|
use super::models::data::{Database, GameVersion};
|
||||||
pub struct DatabaseAuth {
|
|
||||||
pub private: String,
|
|
||||||
pub cert: String,
|
|
||||||
pub client_id: String,
|
|
||||||
pub web_token: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Strings are version names for a particular game
|
|
||||||
#[derive(Serialize, Clone, Deserialize)]
|
|
||||||
#[serde(tag = "type")]
|
|
||||||
pub enum GameDownloadStatus {
|
|
||||||
Remote {},
|
|
||||||
SetupRequired {
|
|
||||||
version_name: String,
|
|
||||||
install_dir: String,
|
|
||||||
},
|
|
||||||
Installed {
|
|
||||||
version_name: String,
|
|
||||||
install_dir: String,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
// Stuff that shouldn't be synced to disk
|
|
||||||
#[derive(Clone, Serialize, Deserialize)]
|
|
||||||
pub enum ApplicationTransientStatus {
|
|
||||||
Downloading { version_name: String },
|
|
||||||
Uninstalling {},
|
|
||||||
Updating { version_name: String },
|
|
||||||
Running {},
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_template() -> String {
|
|
||||||
"{}".to_owned()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct GameVersion {
|
|
||||||
pub game_id: String,
|
|
||||||
pub version_name: String,
|
|
||||||
|
|
||||||
pub platform: Platform,
|
|
||||||
|
|
||||||
pub launch_command: String,
|
|
||||||
pub launch_args: Vec<String>,
|
|
||||||
#[serde(default = "default_template")]
|
|
||||||
pub launch_command_template: String,
|
|
||||||
|
|
||||||
pub setup_command: String,
|
|
||||||
pub setup_args: Vec<String>,
|
|
||||||
#[serde(default = "default_template")]
|
|
||||||
pub setup_command_template: String,
|
|
||||||
|
|
||||||
pub only_setup: bool,
|
|
||||||
|
|
||||||
pub version_index: usize,
|
|
||||||
pub delta: bool,
|
|
||||||
|
|
||||||
pub umu_id_override: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[serde_as]
|
|
||||||
#[derive(Serialize, Clone, Deserialize, Default)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct DatabaseApplications {
|
|
||||||
pub install_dirs: Vec<PathBuf>,
|
|
||||||
// Guaranteed to exist if the game also exists in the app state map
|
|
||||||
pub game_statuses: HashMap<String, GameDownloadStatus>,
|
|
||||||
pub game_versions: HashMap<String, HashMap<String, GameVersion>>,
|
|
||||||
pub installed_game_version: HashMap<String, DownloadableMetadata>,
|
|
||||||
|
|
||||||
#[serde(skip)]
|
|
||||||
pub transient_statuses: HashMap<DownloadableMetadata, ApplicationTransientStatus>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Default)]
|
|
||||||
pub struct Database {
|
|
||||||
#[serde(default)]
|
|
||||||
pub settings: Settings,
|
|
||||||
pub auth: Option<DatabaseAuth>,
|
|
||||||
pub base_url: String,
|
|
||||||
pub applications: DatabaseApplications,
|
|
||||||
pub prev_database: Option<PathBuf>,
|
|
||||||
pub cache_dir: PathBuf,
|
|
||||||
}
|
|
||||||
impl Database {
|
|
||||||
fn new<T: Into<PathBuf>>(
|
|
||||||
games_base_dir: T,
|
|
||||||
prev_database: Option<PathBuf>,
|
|
||||||
cache_dir: PathBuf,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
|
||||||
applications: DatabaseApplications {
|
|
||||||
install_dirs: vec![games_base_dir.into()],
|
|
||||||
game_statuses: HashMap::new(),
|
|
||||||
game_versions: HashMap::new(),
|
|
||||||
installed_game_version: HashMap::new(),
|
|
||||||
transient_statuses: HashMap::new(),
|
|
||||||
},
|
|
||||||
prev_database,
|
|
||||||
base_url: "".to_owned(),
|
|
||||||
auth: None,
|
|
||||||
settings: Settings::default(),
|
|
||||||
cache_dir,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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")));
|
||||||
|
|
||||||
@ -138,13 +26,20 @@ pub static DATA_ROOT_DIR: LazyLock<Mutex<PathBuf>> =
|
|||||||
#[derive(Debug, Default, Clone)]
|
#[derive(Debug, Default, Clone)]
|
||||||
pub struct DropDatabaseSerializer;
|
pub struct DropDatabaseSerializer;
|
||||||
|
|
||||||
impl<T: Serialize + DeserializeOwned> DeSerializer<T> for DropDatabaseSerializer {
|
impl<T: native_model::Model + Serialize + DeserializeOwned> DeSerializer<T>
|
||||||
|
for DropDatabaseSerializer
|
||||||
|
{
|
||||||
fn serialize(&self, val: &T) -> rustbreak::error::DeSerResult<Vec<u8>> {
|
fn serialize(&self, val: &T) -> rustbreak::error::DeSerResult<Vec<u8>> {
|
||||||
serde_json::to_vec(val).map_err(|e| DeSerError::Internal(e.to_string()))
|
native_model::encode(val).map_err(|e| DeSerError::Internal(e.to_string()))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deserialize<R: std::io::Read>(&self, s: R) -> rustbreak::error::DeSerResult<T> {
|
fn deserialize<R: std::io::Read>(&self, mut s: R) -> rustbreak::error::DeSerResult<T> {
|
||||||
serde_json::from_reader(s).map_err(|e| DeSerError::Internal(e.to_string()))
|
let mut buf = Vec::new();
|
||||||
|
s.read_to_end(&mut buf)
|
||||||
|
.map_err(|e| rustbreak::error::DeSerError::Other(e.into()))?;
|
||||||
|
let (val, _version) =
|
||||||
|
native_model::decode::<T>(buf).map_err(|e| DeSerError::Internal(e.to_string()))?;
|
||||||
|
Ok(val)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
pub mod commands;
|
pub mod commands;
|
||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod debug;
|
pub mod debug;
|
||||||
pub mod settings;
|
pub mod models;
|
||||||
184
src-tauri/src/database/models.rs
Normal file
184
src-tauri/src/database/models.rs
Normal file
@ -0,0 +1,184 @@
|
|||||||
|
pub mod data {
|
||||||
|
use native_model::{native_model, Model};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
pub type GameVersion = v1::GameVersion;
|
||||||
|
pub type Database = v1::Database;
|
||||||
|
pub type Settings = v1::Settings;
|
||||||
|
pub type DatabaseAuth = v1::DatabaseAuth;
|
||||||
|
|
||||||
|
pub type GameDownloadStatus = v1::GameDownloadStatus;
|
||||||
|
pub type ApplicationTransientStatus = v1::ApplicationTransientStatus;
|
||||||
|
pub type DownloadableMetadata = v1::DownloadableMetadata;
|
||||||
|
pub type DownloadType = v1::DownloadType;
|
||||||
|
|
||||||
|
pub mod v1 {
|
||||||
|
use crate::process::process_manager::Platform;
|
||||||
|
use serde_with::serde_as;
|
||||||
|
use std::{collections::HashMap, path::PathBuf};
|
||||||
|
|
||||||
|
use super::*;
|
||||||
|
|
||||||
|
fn default_template() -> String {
|
||||||
|
"{}".to_owned()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[native_model(id = 2, version = 1)]
|
||||||
|
pub struct GameVersion {
|
||||||
|
pub game_id: String,
|
||||||
|
pub version_name: String,
|
||||||
|
|
||||||
|
pub platform: Platform,
|
||||||
|
|
||||||
|
pub launch_command: String,
|
||||||
|
pub launch_args: Vec<String>,
|
||||||
|
#[serde(default = "default_template")]
|
||||||
|
pub launch_command_template: String,
|
||||||
|
|
||||||
|
pub setup_command: String,
|
||||||
|
pub setup_args: Vec<String>,
|
||||||
|
#[serde(default = "default_template")]
|
||||||
|
pub setup_command_template: String,
|
||||||
|
|
||||||
|
pub only_setup: bool,
|
||||||
|
|
||||||
|
pub version_index: usize,
|
||||||
|
pub delta: bool,
|
||||||
|
|
||||||
|
pub umu_id_override: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[serde_as]
|
||||||
|
#[derive(Serialize, Clone, Deserialize, Default)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[native_model(id = 3, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)]
|
||||||
|
pub struct DatabaseApplications {
|
||||||
|
pub install_dirs: Vec<PathBuf>,
|
||||||
|
// Guaranteed to exist if the game also exists in the app state map
|
||||||
|
pub game_statuses: HashMap<String, GameDownloadStatus>,
|
||||||
|
pub game_versions: HashMap<String, HashMap<String, GameVersion>>,
|
||||||
|
pub installed_game_version: HashMap<String, DownloadableMetadata>,
|
||||||
|
|
||||||
|
#[serde(skip)]
|
||||||
|
pub transient_statuses: HashMap<DownloadableMetadata, ApplicationTransientStatus>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[native_model(id = 4, version = 1)]
|
||||||
|
pub struct Settings {
|
||||||
|
pub autostart: bool,
|
||||||
|
pub max_download_threads: usize,
|
||||||
|
pub force_offline: bool, // ... other settings ...
|
||||||
|
}
|
||||||
|
impl Default for Settings {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
autostart: false,
|
||||||
|
max_download_threads: 4,
|
||||||
|
force_offline: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Strings are version names for a particular game
|
||||||
|
#[derive(Serialize, Clone, Deserialize)]
|
||||||
|
#[serde(tag = "type")]
|
||||||
|
#[native_model(id = 5, version = 1)]
|
||||||
|
pub enum GameDownloadStatus {
|
||||||
|
Remote {},
|
||||||
|
SetupRequired {
|
||||||
|
version_name: String,
|
||||||
|
install_dir: String,
|
||||||
|
},
|
||||||
|
Installed {
|
||||||
|
version_name: String,
|
||||||
|
install_dir: String,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stuff that shouldn't be synced to disk
|
||||||
|
#[derive(Clone, Serialize, Deserialize)]
|
||||||
|
pub enum ApplicationTransientStatus {
|
||||||
|
Downloading { version_name: String },
|
||||||
|
Uninstalling {},
|
||||||
|
Updating { version_name: String },
|
||||||
|
Running {},
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(serde::Serialize, Clone, Deserialize)]
|
||||||
|
#[native_model(id = 6, version = 1)]
|
||||||
|
pub struct DatabaseAuth {
|
||||||
|
pub private: String,
|
||||||
|
pub cert: String,
|
||||||
|
pub client_id: String,
|
||||||
|
pub web_token: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[native_model(id = 8, version = 1)]
|
||||||
|
#[derive(
|
||||||
|
Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone, Copy,
|
||||||
|
)]
|
||||||
|
pub enum DownloadType {
|
||||||
|
Game,
|
||||||
|
Tool,
|
||||||
|
DLC,
|
||||||
|
Mod,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[native_model(id = 7, version = 1)]
|
||||||
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone)]
|
||||||
|
#[serde(rename_all = "camelCase")]
|
||||||
|
pub struct DownloadableMetadata {
|
||||||
|
pub id: String,
|
||||||
|
pub version: Option<String>,
|
||||||
|
pub download_type: DownloadType,
|
||||||
|
}
|
||||||
|
impl DownloadableMetadata {
|
||||||
|
pub fn new(id: String, version: Option<String>, download_type: DownloadType) -> Self {
|
||||||
|
Self {
|
||||||
|
id,
|
||||||
|
version,
|
||||||
|
download_type,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[native_model(id = 1, version = 1)]
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Default)]
|
||||||
|
pub struct Database {
|
||||||
|
#[serde(default)]
|
||||||
|
pub settings: Settings,
|
||||||
|
pub auth: Option<DatabaseAuth>,
|
||||||
|
pub base_url: String,
|
||||||
|
pub applications: DatabaseApplications,
|
||||||
|
pub prev_database: Option<PathBuf>,
|
||||||
|
pub cache_dir: PathBuf,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Database {
|
||||||
|
pub fn new<T: Into<PathBuf>>(
|
||||||
|
games_base_dir: T,
|
||||||
|
prev_database: Option<PathBuf>,
|
||||||
|
cache_dir: PathBuf,
|
||||||
|
) -> Self {
|
||||||
|
Self {
|
||||||
|
applications: DatabaseApplications {
|
||||||
|
install_dirs: vec![games_base_dir.into()],
|
||||||
|
game_statuses: HashMap::new(),
|
||||||
|
game_versions: HashMap::new(),
|
||||||
|
installed_game_version: HashMap::new(),
|
||||||
|
transient_statuses: HashMap::new(),
|
||||||
|
},
|
||||||
|
prev_database,
|
||||||
|
base_url: "".to_owned(),
|
||||||
|
auth: None,
|
||||||
|
settings: Settings::default(),
|
||||||
|
cache_dir,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,26 +0,0 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct Settings {
|
|
||||||
pub autostart: bool,
|
|
||||||
pub max_download_threads: usize,
|
|
||||||
pub force_offline: bool
|
|
||||||
// ... other settings ...
|
|
||||||
}
|
|
||||||
impl Default for Settings {
|
|
||||||
fn default() -> Self {
|
|
||||||
Self {
|
|
||||||
autostart: false,
|
|
||||||
max_download_threads: 4,
|
|
||||||
force_offline: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Ideally use pointers instead of a macro to assign the settings
|
|
||||||
// fn deserialize_into<T>(v: serde_json::Value, t: &mut T) -> Result<(), serde_json::Error>
|
|
||||||
// where T: for<'a> Deserialize<'a>
|
|
||||||
// {
|
|
||||||
// *t = serde_json::from_value(v)?;
|
|
||||||
// Ok(())
|
|
||||||
// }
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use crate::{download_manager::downloadable_metadata::DownloadableMetadata, AppState};
|
use crate::{database::models::data::DownloadableMetadata, AppState};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn pause_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
pub fn pause_downloads(state: tauri::State<'_, Mutex<AppState>>) {
|
||||||
|
|||||||
@ -12,11 +12,10 @@ use std::{
|
|||||||
use log::{debug, info};
|
use log::{debug, info};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use crate::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},
|
||||||
downloadable_metadata::DownloadableMetadata,
|
|
||||||
queue::Queue,
|
queue::Queue,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -167,10 +166,7 @@ impl DownloadManager {
|
|||||||
self.command_sender
|
self.command_sender
|
||||||
.send(DownloadManagerSignal::UpdateUIQueue)
|
.send(DownloadManagerSignal::UpdateUIQueue)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
self.command_sender
|
self.command_sender.send(DownloadManagerSignal::Go).unwrap();
|
||||||
.send(DownloadManagerSignal::Go)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
pub fn pause_downloads(&self) {
|
pub fn pause_downloads(&self) {
|
||||||
self.command_sender
|
self.command_sender
|
||||||
|
|||||||
@ -11,15 +11,13 @@ use log::{debug, error, info, warn};
|
|||||||
use tauri::{AppHandle, Emitter};
|
use tauri::{AppHandle, Emitter};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
error::application_download_error::ApplicationDownloadError,
|
database::models::data::DownloadableMetadata, error::application_download_error::ApplicationDownloadError, games::library::{QueueUpdateEvent, QueueUpdateEventQueueData, StatsUpdateEvent}
|
||||||
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},
|
download_thread_control_flag::{DownloadThreadControl, DownloadThreadControlFlag},
|
||||||
downloadable::Downloadable,
|
downloadable::Downloadable,
|
||||||
downloadable_metadata::DownloadableMetadata,
|
|
||||||
progress_object::ProgressObject,
|
progress_object::ProgressObject,
|
||||||
queue::Queue,
|
queue::Queue,
|
||||||
};
|
};
|
||||||
@ -209,7 +207,9 @@ impl DownloadManagerBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.current_download_agent.is_some() {
|
if self.current_download_agent.is_some() {
|
||||||
if self.download_queue.read().front().unwrap() == &self.current_download_agent.as_ref().unwrap().metadata() {
|
if self.download_queue.read().front().unwrap()
|
||||||
|
== &self.current_download_agent.as_ref().unwrap().metadata()
|
||||||
|
{
|
||||||
debug!(
|
debug!(
|
||||||
"Current download agent: {:?}",
|
"Current download agent: {:?}",
|
||||||
self.current_download_agent.as_ref().unwrap().metadata()
|
self.current_download_agent.as_ref().unwrap().metadata()
|
||||||
|
|||||||
@ -2,11 +2,11 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use tauri::AppHandle;
|
use tauri::AppHandle;
|
||||||
|
|
||||||
use crate::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, download_thread_control_flag::DownloadThreadControl,
|
||||||
downloadable_metadata::DownloadableMetadata, progress_object::ProgressObject,
|
progress_object::ProgressObject,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub trait Downloadable: Send + Sync {
|
pub trait Downloadable: Send + Sync {
|
||||||
|
|||||||
@ -1,26 +1 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone, Copy)]
|
|
||||||
pub enum DownloadType {
|
|
||||||
Game,
|
|
||||||
Tool,
|
|
||||||
DLC,
|
|
||||||
Mod,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize, Clone)]
|
|
||||||
#[serde(rename_all = "camelCase")]
|
|
||||||
pub struct DownloadableMetadata {
|
|
||||||
pub id: String,
|
|
||||||
pub version: Option<String>,
|
|
||||||
pub download_type: DownloadType,
|
|
||||||
}
|
|
||||||
impl DownloadableMetadata {
|
|
||||||
pub fn new(id: String, version: Option<String>, download_type: DownloadType) -> Self {
|
|
||||||
Self {
|
|
||||||
id,
|
|
||||||
version,
|
|
||||||
download_type,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -3,7 +3,7 @@ use std::{
|
|||||||
sync::{Arc, Mutex, MutexGuard},
|
sync::{Arc, Mutex, MutexGuard},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::downloadable_metadata::DownloadableMetadata;
|
use crate::database::models::data::DownloadableMetadata;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct Queue {
|
pub struct Queue {
|
||||||
|
|||||||
@ -3,7 +3,13 @@ use std::sync::Mutex;
|
|||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::db::GameVersion, error::{library_error::LibraryError, remote_access_error::RemoteAccessError}, games::library::{fetch_game_logic_offline, fetch_library_logic_offline, get_current_meta, uninstall_game_logic}, offline, AppState
|
database::models::data::GameVersion,
|
||||||
|
error::{library_error::LibraryError, remote_access_error::RemoteAccessError},
|
||||||
|
games::library::{
|
||||||
|
fetch_game_logic_offline, fetch_library_logic_offline, get_current_meta,
|
||||||
|
uninstall_game_logic,
|
||||||
|
},
|
||||||
|
offline, AppState,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
@ -15,16 +21,29 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn fetch_library(state: tauri::State<'_, Mutex<AppState>>) -> Result<Vec<Game>, RemoteAccessError> {
|
pub fn fetch_library(
|
||||||
offline!(state, fetch_library_logic, fetch_library_logic_offline, state)
|
state: tauri::State<'_, Mutex<AppState>>,
|
||||||
|
) -> Result<Vec<Game>, RemoteAccessError> {
|
||||||
|
offline!(
|
||||||
|
state,
|
||||||
|
fetch_library_logic,
|
||||||
|
fetch_library_logic_offline,
|
||||||
|
state
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
pub fn fetch_game(
|
pub fn fetch_game(
|
||||||
game_id: String,
|
game_id: String,
|
||||||
state: tauri::State<'_, Mutex<AppState>>
|
state: tauri::State<'_, Mutex<AppState>>,
|
||||||
) -> Result<FetchGameStruct, RemoteAccessError> {
|
) -> Result<FetchGameStruct, RemoteAccessError> {
|
||||||
offline!(state, fetch_game_logic, fetch_game_logic_offline, game_id, state)
|
offline!(
|
||||||
|
state,
|
||||||
|
fetch_game_logic,
|
||||||
|
fetch_game_logic_offline,
|
||||||
|
game_id,
|
||||||
|
state
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
|
|||||||
@ -1,14 +1,11 @@
|
|||||||
use crate::auth::generate_authorization_header;
|
use crate::auth::generate_authorization_header;
|
||||||
use crate::database::db::{
|
use crate::database::db::borrow_db_checked;
|
||||||
borrow_db_checked, ApplicationTransientStatus, DatabaseImpls,
|
use crate::database::models::data::{ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus};
|
||||||
GameDownloadStatus,
|
|
||||||
};
|
|
||||||
use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus};
|
use crate::download_manager::download_manager::{DownloadManagerSignal, DownloadStatus};
|
||||||
use crate::download_manager::download_thread_control_flag::{
|
use crate::download_manager::download_thread_control_flag::{
|
||||||
DownloadThreadControl, DownloadThreadControlFlag,
|
DownloadThreadControl, DownloadThreadControlFlag,
|
||||||
};
|
};
|
||||||
use crate::download_manager::downloadable::Downloadable;
|
use crate::download_manager::downloadable::Downloadable;
|
||||||
use crate::download_manager::downloadable_metadata::{DownloadType, DownloadableMetadata};
|
|
||||||
use crate::download_manager::progress_object::{ProgressHandle, ProgressObject};
|
use crate::download_manager::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;
|
||||||
@ -25,7 +22,6 @@ use std::sync::mpsc::Sender;
|
|||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
use tauri::{AppHandle, Emitter};
|
use tauri::{AppHandle, Emitter};
|
||||||
use urlencoding::encode;
|
|
||||||
|
|
||||||
#[cfg(target_os = "linux")]
|
#[cfg(target_os = "linux")]
|
||||||
use rustix::fs::{fallocate, FallocateFlags};
|
use rustix::fs::{fallocate, FallocateFlags};
|
||||||
@ -377,7 +373,10 @@ impl Downloadable for GameDownloadAgent {
|
|||||||
error!("error while managing download: {}", error);
|
error!("error while managing download: {}", error);
|
||||||
|
|
||||||
let mut handle = DB.borrow_data_mut().unwrap();
|
let mut handle = DB.borrow_data_mut().unwrap();
|
||||||
handle.applications.transient_statuses.remove(&self.metadata());
|
handle
|
||||||
|
.applications
|
||||||
|
.transient_statuses
|
||||||
|
.remove(&self.metadata());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_complete(&self, app_handle: &tauri::AppHandle) {
|
fn on_complete(&self, app_handle: &tauri::AppHandle) {
|
||||||
|
|||||||
@ -7,10 +7,9 @@ use serde::{Deserialize, Serialize};
|
|||||||
use tauri::Emitter;
|
use tauri::Emitter;
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle, Manager};
|
||||||
|
|
||||||
use crate::database::db::{borrow_db_checked, borrow_db_mut_checked, save_db, GameVersion};
|
use crate::database::db::{borrow_db_checked, borrow_db_mut_checked, save_db};
|
||||||
use crate::database::db::{ApplicationTransientStatus, GameDownloadStatus};
|
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::download_manager::downloadable_metadata::DownloadableMetadata;
|
|
||||||
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;
|
||||||
use crate::games::state::{GameStatusManager, GameStatusWithTransient};
|
use crate::games::state::{GameStatusManager, GameStatusWithTransient};
|
||||||
@ -438,7 +437,12 @@ pub fn on_game_complete(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_game_update(app_handle: &AppHandle, game_id: &String, version: Option<GameVersion>, status: GameStatusWithTransient) {
|
pub fn push_game_update(
|
||||||
|
app_handle: &AppHandle,
|
||||||
|
game_id: &String,
|
||||||
|
version: Option<GameVersion>,
|
||||||
|
status: GameStatusWithTransient,
|
||||||
|
) {
|
||||||
app_handle
|
app_handle
|
||||||
.emit(
|
.emit(
|
||||||
&format!("update_game/{}", game_id),
|
&format!("update_game/{}", game_id),
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
use crate::database::db::{borrow_db_checked, ApplicationTransientStatus, GameDownloadStatus};
|
use crate::database::{db::borrow_db_checked, models::data::{ApplicationTransientStatus, GameDownloadStatus}};
|
||||||
|
|
||||||
pub type GameStatusWithTransient = (
|
pub type GameStatusWithTransient = (
|
||||||
Option<GameDownloadStatus>,
|
Option<GameDownloadStatus>,
|
||||||
|
|||||||
@ -17,9 +17,8 @@ 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,
|
||||||
};
|
};
|
||||||
use database::db::{
|
use database::db::{borrow_db_checked, borrow_db_mut_checked, DatabaseInterface, DATA_ROOT_DIR};
|
||||||
borrow_db_checked, borrow_db_mut_checked, DatabaseInterface, GameDownloadStatus, DATA_ROOT_DIR,
|
use database::models::data::GameDownloadStatus;
|
||||||
};
|
|
||||||
use download_manager::commands::{
|
use download_manager::commands::{
|
||||||
cancel_game, move_download_in_queue, pause_downloads, resume_downloads,
|
cancel_game, move_download_in_queue, pause_downloads, resume_downloads,
|
||||||
};
|
};
|
||||||
@ -35,7 +34,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 http::Response;
|
||||||
use http::{header::*, response::Builder as ResponseBuilder};
|
|
||||||
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;
|
||||||
@ -89,7 +87,6 @@ pub struct User {
|
|||||||
profile_picture_object_id: String,
|
profile_picture_object_id: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Clone, Serialize)]
|
#[derive(Clone, Serialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct AppState<'a> {
|
pub struct AppState<'a> {
|
||||||
@ -161,8 +158,8 @@ fn setup(handle: AppHandle) -> AppState<'static> {
|
|||||||
drop(db_handle);
|
drop(db_handle);
|
||||||
for (game_id, status) in statuses.into_iter() {
|
for (game_id, status) in statuses.into_iter() {
|
||||||
match status {
|
match status {
|
||||||
database::db::GameDownloadStatus::Remote {} => {}
|
GameDownloadStatus::Remote {} => {}
|
||||||
database::db::GameDownloadStatus::SetupRequired {
|
GameDownloadStatus::SetupRequired {
|
||||||
version_name: _,
|
version_name: _,
|
||||||
install_dir,
|
install_dir,
|
||||||
} => {
|
} => {
|
||||||
@ -171,7 +168,7 @@ fn setup(handle: AppHandle) -> AppState<'static> {
|
|||||||
missing_games.push(game_id);
|
missing_games.push(game_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
database::db::GameDownloadStatus::Installed {
|
GameDownloadStatus::Installed {
|
||||||
version_name: _,
|
version_name: _,
|
||||||
install_dir,
|
install_dir,
|
||||||
} => {
|
} => {
|
||||||
@ -290,7 +287,7 @@ pub fn run() {
|
|||||||
|
|
||||||
{
|
{
|
||||||
use tauri_plugin_deep_link::DeepLinkExt;
|
use tauri_plugin_deep_link::DeepLinkExt;
|
||||||
app.deep_link().register_all()?;
|
let _ = app.deep_link().register_all();
|
||||||
debug!("registered all pre-defined deep links");
|
debug!("registered all pre-defined deep links");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -393,7 +390,6 @@ pub fn run() {
|
|||||||
request,
|
request,
|
||||||
responder
|
responder
|
||||||
);
|
);
|
||||||
|
|
||||||
})
|
})
|
||||||
.on_window_event(|window, event| {
|
.on_window_event(|window, event| {
|
||||||
if let WindowEvent::CloseRequested { api, .. } = event {
|
if let WindowEvent::CloseRequested { api, .. } = event {
|
||||||
|
|||||||
@ -18,11 +18,10 @@ use tauri::{AppHandle, Manager};
|
|||||||
use umu_wrapper_lib::command_builder::UmuCommandBuilder;
|
use umu_wrapper_lib::command_builder::UmuCommandBuilder;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::db::{
|
database::{
|
||||||
borrow_db_mut_checked, ApplicationTransientStatus, GameDownloadStatus, GameVersion,
|
db::{borrow_db_mut_checked, DATA_ROOT_DIR},
|
||||||
DATA_ROOT_DIR,
|
models::data::{ApplicationTransientStatus, DownloadType, DownloadableMetadata, GameDownloadStatus, GameVersion},
|
||||||
},
|
},
|
||||||
download_manager::downloadable_metadata::{DownloadType, DownloadableMetadata},
|
|
||||||
error::process_error::ProcessError,
|
error::process_error::ProcessError,
|
||||||
games::{library::push_game_update, state::GameStatusManager},
|
games::{library::push_game_update, state::GameStatusManager},
|
||||||
AppState, DB,
|
AppState, DB,
|
||||||
|
|||||||
@ -10,9 +10,7 @@ use tauri::{AppHandle, Emitter, Manager};
|
|||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
database::db::{
|
database::{db::{borrow_db_checked, borrow_db_mut_checked, save_db, DatabaseImpls}, models::data::DatabaseAuth},
|
||||||
borrow_db_checked, borrow_db_mut_checked, save_db, DatabaseAuth, DatabaseImpls,
|
|
||||||
},
|
|
||||||
error::{drop_server_error::DropServerError, remote_access_error::RemoteAccessError},
|
error::{drop_server_error::DropServerError, remote_access_error::RemoteAccessError},
|
||||||
AppState, AppStatus, User, DB,
|
AppState, AppStatus, User, DB,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -1,15 +1,11 @@
|
|||||||
use std::sync::RwLockReadGuard;
|
use std::sync::RwLockReadGuard;
|
||||||
|
|
||||||
use crate::{
|
use crate::{database::{db::borrow_db_checked, models::data::Database}, error::remote_access_error::RemoteAccessError};
|
||||||
database::db::{borrow_db_checked, Database},
|
|
||||||
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};
|
||||||
use serde_binary::binary_stream::Endian;
|
use serde_binary::binary_stream::Endian;
|
||||||
|
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! offline {
|
macro_rules! offline {
|
||||||
($var:expr, $func1:expr, $func2:expr, $( $arg:expr ),* ) => {
|
($var:expr, $func1:expr, $func2:expr, $( $arg:expr ),* ) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user