From 97b5cd5e789bf8b83df17ea00605acb49df366d6 Mon Sep 17 00:00:00 2001 From: quexeky <116044207+quexeky@users.noreply.github.com> Date: Fri, 5 Sep 2025 15:31:28 +1000 Subject: [PATCH 1/3] Native model fixes (#137) * fix: Fix native_model from requirements and add version requirements for models Signed-off-by: quexeky * fix: Use Drop-OSS/native_model Signed-off-by: quexeky * chore: Bump version to include logging (Albeit, logging occurs before we initialise the logger, but oh well) Signed-off-by: quexeky * chore: Make clippy happy Signed-off-by: quexeky --------- Signed-off-by: quexeky --- src-tauri/Cargo.lock | 12 ++++---- src-tauri/Cargo.toml | 2 +- src-tauri/src/database/db.rs | 5 ++-- src-tauri/src/database/models.rs | 50 +++++++++++++++----------------- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index a95f43c..8f8888c 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -3118,13 +3118,13 @@ dependencies = [ [[package]] name = "native_model" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7050d759e3da6673361dddda4f4a743492279dd2c6484a21fbee0a8278620df0" +version = "0.6.4" +source = "git+https://github.com/Drop-OSS/native_model.git#a91b422cbd53116df1f20b2459fb3d8257458bfd" dependencies = [ "anyhow", "bincode", "doc-comment", + "log", "native_model_macro", "rmp-serde", "serde", @@ -3134,10 +3134,10 @@ dependencies = [ [[package]] name = "native_model_macro" -version = "0.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1577a0bebf5ed1754e240baf5d9b1845f51e598b20600aa894f55e11cd20cc6c" +version = "0.6.4" +source = "git+https://github.com/Drop-OSS/native_model.git#a91b422cbd53116df1f20b2459fb3d8257458bfd" dependencies = [ + "log", "proc-macro2", "quote", "syn 2.0.101", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index f999d73..b4cec7b 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -65,7 +65,7 @@ whoami = "1.6.0" filetime = "0.2.25" walkdir = "2.5.0" known-folders = "1.2.0" -native_model = { version = "0.6.1", features = ["rmp_serde_1_3"] } +native_model = { version = "0.6.4", features = ["rmp_serde_1_3"], git = "https://github.com/Drop-OSS/native_model.git"} tauri-plugin-opener = "2.4.0" bitcode = "0.6.6" reqwest-websocket = "0.5.0" diff --git a/src-tauri/src/database/db.rs b/src-tauri/src/database/db.rs index bc08f7a..3e8bc05 100644 --- a/src-tauri/src/database/db.rs +++ b/src-tauri/src/database/db.rs @@ -8,7 +8,6 @@ use std::{ use chrono::Utc; use log::{debug, error, info, warn}; -use native_model::{Decode, Encode}; use rustbreak::{DeSerError, DeSerializer, PathDatabase, RustbreakError}; use serde::{Serialize, de::DeserializeOwned}; use url::Url; @@ -28,7 +27,7 @@ impl DeSerializer for DropDatabaseSerializer { fn serialize(&self, val: &T) -> rustbreak::error::DeSerResult> { - native_model::rmp_serde_1_3::RmpSerde::encode(val) + native_model::encode(val) .map_err(|e| DeSerError::Internal(e.to_string())) } @@ -36,7 +35,7 @@ impl DeSerializer let mut buf = Vec::new(); s.read_to_end(&mut buf) .map_err(|e| rustbreak::error::DeSerError::Other(e.into()))?; - let val = native_model::rmp_serde_1_3::RmpSerde::decode(buf) + let (val, _version) = native_model::decode(buf) .map_err(|e| DeSerError::Internal(e.to_string()))?; Ok(val) } diff --git a/src-tauri/src/database/models.rs b/src-tauri/src/database/models.rs index a2997b2..1177f4e 100644 --- a/src-tauri/src/database/models.rs +++ b/src-tauri/src/database/models.rs @@ -1,10 +1,5 @@ -/** - * NEXT BREAKING CHANGE - * - * UPDATE DATABASE TO USE RPMSERDENAMED - * - * WE CAN'T DELETE ANY FIELDS - */ + + pub mod data { use std::path::PathBuf; @@ -12,6 +7,9 @@ pub mod data { use native_model::native_model; use serde::{Deserialize, Serialize}; + // NOTE: Within each version, you should NEVER use these types. + // Declare it using the actual version that it is from, i.e. v1::Settings rather than just Settings from here + pub type GameVersion = v1::GameVersion; pub type Database = v3::Database; pub type Settings = v1::Settings; @@ -22,7 +20,7 @@ pub mod data { pub type DownloadableMetadata = v1::DownloadableMetadata; pub type DownloadType = v1::DownloadType; pub type DatabaseApplications = v2::DatabaseApplications; - pub type DatabaseCompatInfo = v2::DatabaseCompatInfo; + // pub type DatabaseCompatInfo = v2::DatabaseCompatInfo; use std::collections::HashMap; @@ -180,16 +178,15 @@ pub mod data { use serde_with::serde_as; use super::{ - ApplicationTransientStatus, DatabaseAuth, Deserialize, DownloadableMetadata, - GameVersion, Serialize, Settings, native_model, v1, + Deserialize, Serialize, native_model, v1, }; - #[native_model(id = 1, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)] + #[native_model(id = 1, version = 2, with = native_model::rmp_serde_1_3::RmpSerde, from = v1::Database)] #[derive(Serialize, Deserialize, Clone, Default)] pub struct Database { #[serde(default)] - pub settings: Settings, - pub auth: Option, + pub settings: v1::Settings, + pub auth: Option, pub base_url: String, pub applications: v1::DatabaseApplications, #[serde(skip)] @@ -198,7 +195,7 @@ pub mod data { pub compat_info: Option, } - #[native_model(id = 8, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)] + #[native_model(id = 9, version = 1, with = native_model::rmp_serde_1_3::RmpSerde)] #[derive(Serialize, Deserialize, Clone, Default)] pub struct DatabaseCompatInfo { @@ -221,7 +218,7 @@ pub mod data { // Strings are version names for a particular game #[derive(Serialize, Clone, Deserialize, Debug)] #[serde(tag = "type")] - #[native_model(id = 5, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)] + #[native_model(id = 5, version = 2, with = native_model::rmp_serde_1_3::RmpSerde, from = v1::GameDownloadStatus)] pub enum GameDownloadStatus { Remote {}, SetupRequired { @@ -261,17 +258,17 @@ pub mod data { #[serde_as] #[derive(Serialize, Clone, Deserialize, Default)] #[serde(rename_all = "camelCase")] - #[native_model(id = 3, version = 2, with = native_model::rmp_serde_1_3::RmpSerde)] + #[native_model(id = 3, version = 2, with = native_model::rmp_serde_1_3::RmpSerde, from=v1::DatabaseApplications)] pub struct DatabaseApplications { pub install_dirs: Vec, // Guaranteed to exist if the game also exists in the app state map pub game_statuses: HashMap, - pub game_versions: HashMap>, - pub installed_game_version: HashMap, + pub game_versions: HashMap>, + pub installed_game_version: HashMap, #[serde(skip)] - pub transient_statuses: HashMap, + pub transient_statuses: HashMap, } impl From for DatabaseApplications { fn from(value: v1::DatabaseApplications) -> Self { @@ -293,21 +290,21 @@ pub mod data { use std::path::PathBuf; use super::{ - DatabaseApplications, DatabaseAuth, DatabaseCompatInfo, Deserialize, Serialize, - Settings, native_model, v2, + Deserialize, Serialize, + native_model, v2, v1, }; - #[native_model(id = 1, version = 3, with = native_model::rmp_serde_1_3::RmpSerde)] + #[native_model(id = 1, version = 3, with = native_model::rmp_serde_1_3::RmpSerde, from = v2::Database)] #[derive(Serialize, Deserialize, Clone, Default)] pub struct Database { #[serde(default)] - pub settings: Settings, - pub auth: Option, + pub settings: v1::Settings, + pub auth: Option, pub base_url: String, - pub applications: DatabaseApplications, + pub applications: v2::DatabaseApplications, #[serde(skip)] pub prev_database: Option, pub cache_dir: PathBuf, - pub compat_info: Option, + pub compat_info: Option, } impl From for Database { @@ -347,5 +344,6 @@ pub mod data { compat_info: None, } } + } } From 3f18d15d395ef28519bccf18ed04dac993cab6fe Mon Sep 17 00:00:00 2001 From: DecDuck Date: Sun, 7 Sep 2025 15:57:06 +1000 Subject: [PATCH 2/3] Collections & download stability, UI (#130) * feat: different local path in dev #73 * feat: better error output for downloads * feat: collections in library view * feat: improve download manager reliability * feat: new download UI, more stable downloads * fix: clippy * fix: only show admin link if user is admin * feat: check for libs before building --- build.mjs | 7 + main/app.vue | 2 +- main/components/HeaderUserWidget.vue | 2 +- main/components/LibrarySearch.vue | 239 +++++++++++++----- main/components/LoadingIndicator.vue | 7 - main/composables/downloads.ts | 2 + main/pages/queue.vue | 34 +-- main/types.ts | 7 + src-tauri/Cargo.lock | 7 +- src-tauri/Cargo.toml | 13 +- src-tauri/src/database/db.rs | 7 +- src-tauri/src/database/models.rs | 27 +- src-tauri/src/database/scan.rs | 4 +- .../download_manager_builder.rs | 88 +++---- .../download_manager_frontend.rs | 2 +- .../src/download_manager/downloadable.rs | 8 +- .../download_manager/util/progress_object.rs | 12 +- .../util/rolling_progress_updates.rs | 13 +- src-tauri/src/games/collections/collection.rs | 5 +- src-tauri/src/games/collections/commands.rs | 20 +- src-tauri/src/games/commands.rs | 4 +- .../src/games/downloads/download_agent.rs | 43 +++- .../src/games/downloads/download_logic.rs | 37 ++- src-tauri/src/games/library.rs | 14 +- src-tauri/src/games/state.rs | 18 +- src-tauri/src/remote/auth.rs | 5 +- src-tauri/src/remote/cache.rs | 17 ++ 27 files changed, 449 insertions(+), 195 deletions(-) delete mode 100644 main/components/LoadingIndicator.vue diff --git a/build.mjs b/build.mjs index c4846f1..051b850 100644 --- a/build.mjs +++ b/build.mjs @@ -21,6 +21,13 @@ async function spawn(exec, opts) { }); } +const expectedLibs = ["drop-base/package.json"]; + +for (const lib of expectedLibs) { + const path = `./libs/${lib}`; + if (!fs.existsSync(path)) throw `Missing "${expectedLibs}". Run "git submodule update --init --recursive"`; +} + const views = fs.readdirSync(".").filter((view) => { const expectedPath = `./${view}/package.json`; return fs.existsSync(expectedPath); diff --git a/main/app.vue b/main/app.vue index 7d4165f..1594dd6 100644 --- a/main/app.vue +++ b/main/app.vue @@ -1,5 +1,5 @@ diff --git a/main/composables/downloads.ts b/main/composables/downloads.ts index d75c46f..f9ab1cd 100644 --- a/main/composables/downloads.ts +++ b/main/composables/downloads.ts @@ -32,3 +32,5 @@ listen("update_stats", (event) => { const stats = useStatsState(); stats.value = event.payload as StatsState; }); + +export const useDownloadHistory = () => useState>('history', () => []); \ No newline at end of file diff --git a/main/pages/queue.vue b/main/pages/queue.vue index 8d5c4ef..30eb886 100644 --- a/main/pages/queue.vue +++ b/main/pages/queue.vue @@ -4,18 +4,18 @@ class="h-16 overflow-hidden relative rounded-xl flex flex-row border border-zinc-900" >
- {{ formatKilobytes(stats.speed) }}/s - {{ formatKilobytes(stats.speed) }}B/s + {{ formatTime(stats.time) }} left
-
+
@@ -62,9 +62,9 @@ class="mt-2 inline-flex items-center gap-x-1 text-zinc-400 text-sm font-display" >{{ formatKilobytes(element.current / 1000) - }} + }}B / - {{ formatKilobytes(element.max / 1000) }}{{ formatKilobytes(element.max / 1000) }}B
@@ -91,7 +91,7 @@