From b199c03c1e61656d0f352e9b893667e39bba45ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Vasconcellos?= Date: Fri, 25 Aug 2023 19:08:34 -0300 Subject: [PATCH] Always enable tauri update + Misc Clippy warns fix (#1250) Always enable tauri update - Fix some misc clippy warnings --- apps/desktop/src-tauri/Cargo.toml | 15 ++++++++++++--- apps/desktop/src-tauri/src/main.rs | 1 - core/src/preferences/library.rs | 13 ++++++++++--- core/src/preferences/mod.rs | 9 +++++++-- core/src/volume/mod.rs | 2 +- crates/crypto/src/keys/keymanager.rs | 3 ++- 6 files changed, 32 insertions(+), 11 deletions(-) diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index 85841d870..946af0168 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -9,7 +9,17 @@ repository = { workspace = true } edition = { workspace = true } [dependencies] -tauri = { version = "1.3.0", features = ["dialog-all", "linux-protocol-headers", "macos-private-api", "os-all", "path-all", "protocol-all", "shell-all", "window-all"] } +tauri = { version = "1.3.0", features = [ + "dialog-all", + "linux-protocol-headers", + "macos-private-api", + "os-all", + "path-all", + "protocol-all", + "shell-all", + "window-all", + "updater", +] } rspc = { workspace = true, features = ["tauri"] } httpz = { workspace = true, features = [ "axum", @@ -50,6 +60,5 @@ sd-desktop-windows = { path = "../crates/windows" } tauri-build = { version = "1.3.0", features = [] } [features] -default = ["custom-protocol", "updater"] -updater = ["tauri/updater"] +default = ["custom-protocol"] custom-protocol = ["tauri/custom-protocol"] diff --git a/apps/desktop/src-tauri/src/main.rs b/apps/desktop/src-tauri/src/main.rs index 0b8238e60..4055cffc9 100644 --- a/apps/desktop/src-tauri/src/main.rs +++ b/apps/desktop/src-tauri/src/main.rs @@ -144,7 +144,6 @@ async fn main() -> tauri::Result<()> { let app = app .setup(|app| { - #[cfg(feature = "updater")] tauri::updater::builder(app.handle()).should_install(|_current, _latest| true); let app = app.handle(); diff --git a/core/src/preferences/library.rs b/core/src/preferences/library.rs index 315624268..8d501315c 100644 --- a/core/src/preferences/library.rs +++ b/core/src/preferences/library.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; use specta::Type; use std::collections::BTreeMap; use std::collections::HashMap; +use tracing::error; use uuid::Uuid; use super::*; @@ -31,9 +32,15 @@ impl LibraryPreferences { let prefs = PreferenceKVs::new( kvs.into_iter() .filter_map(|data| { - let a = rmpv::decode::read_value(&mut data.value?.as_slice()).unwrap(); - - Some((PreferenceKey::new(data.key), PreferenceValue::from_value(a))) + rmpv::decode::read_value(&mut data.value?.as_slice()) + .map_err(|e| error!("{e:#?}")) + .ok() + .map(|value| { + ( + PreferenceKey::new(data.key), + PreferenceValue::from_value(value), + ) + }) }) .collect(), ); diff --git a/core/src/preferences/mod.rs b/core/src/preferences/mod.rs index 101d86255..4209fde3d 100644 --- a/core/src/preferences/mod.rs +++ b/core/src/preferences/mod.rs @@ -7,7 +7,7 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize}; use specta::Type; use std::collections::HashMap; - +use tracing::error; use uuid::Uuid; #[derive(Clone, Serialize, Deserialize, Type, Debug)] @@ -35,7 +35,12 @@ where fn from_entries(entries: Entries) -> Self { entries .into_iter() - .map(|(key, entry)| (Uuid::parse_str(&key).unwrap(), entry.expect_value())) + .filter_map(|(key, entry)| { + Uuid::parse_str(&key) + .map_err(|e| error!("{e:#?}")) + .ok() + .map(|uuid| (uuid, entry.expect_value())) + }) .collect() } } diff --git a/core/src/volume/mod.rs b/core/src/volume/mod.rs index 636904814..19d71a5ec 100644 --- a/core/src/volume/mod.rs +++ b/core/src/volume/mod.rs @@ -125,7 +125,7 @@ pub async fn get_volumes() -> Vec { // Update mount point if not already present let mount_points = &mut volume.mount_points; - if mount_point.iter().all(|p| p != &mount_point) { + if mount_point.iter().all(|p| *p != mount_point) { mount_points.push(mount_point); let mount_points_to_check = mount_points.clone(); mount_points.retain(|candidate| { diff --git a/crates/crypto/src/keys/keymanager.rs b/crates/crypto/src/keys/keymanager.rs index c929342d2..86f9b9a9b 100644 --- a/crates/crypto/src/keys/keymanager.rs +++ b/crates/crypto/src/keys/keymanager.rs @@ -697,7 +697,8 @@ impl KeyManager { self.ensure_not_queued(uuid)?; if let Some(stored_key) = self.keystore.get(&uuid) { - match stored_key.version { + let version = &stored_key.version; + match version { StoredKeyVersion::V1 => { self.mounting_queue.insert(uuid);