Compare commits

...

11 Commits

Author SHA1 Message Date
ac11f91d79 games_in_download: Mutex -> RwLock 2025-08-27 21:29:55 +02:00
8e76e8d1e2 introduce cargo vet 2025-08-27 21:21:01 +02:00
3b6fc80578 [deps] cargo update 2025-08-27 19:55:56 +02:00
8c6fd139c8 [deps] cargo update 2025-08-20 08:54:56 +02:00
66572e16ce [deps] cargo update
Updating anyhow         v1.0.98  -> v1.0.99
Updating async-trait    v0.1.88  -> v0.1.89
Updating bitflags       v2.9.1   -> v2.9.2
Updating brotli         v8.0.1   -> v8.0.2
Updating cc             v1.2.32  -> v1.2.33
Updating clap_builder   v4.5.43  -> v4.5.44
Updating clap_derive    v4.5.41  -> v4.5.45
Updating clap           v4.5.43  -> v4.5.45
Updating dlopen2        v0.7.0   -> v0.8.0
Updating glob           v0.3.2   -> v0.3.3
Updating libc           v0.2.174 -> v0.2.175
Updating objc2          v0.6.1   -> v0.6.2
Updating proc-macro2    v1.0.96  -> v1.0.101
Updating reqwest        v0.12.22 -> v0.12.23
Updating serde-untagged v0.1.7   -> v0.1.8
Updating syn            v2.0.104 -> v2.0.106
Updating tao            v0.34.0  -> v0.34.1
Updating thiserror-impl v2.0.12  -> v2.0.15
Updating thiserror      v2.0.12  -> v2.0.15
Updating uuid           v1.17.0  -> v1.18.0
2025-08-17 16:37:01 +02:00
3b19cb8b18 clippy: apply and fix new lints 2025-08-17 16:35:54 +02:00
61a41c7122 clippy: add same lints to all crates 2025-08-17 16:12:42 +02:00
cbad9389ee code: remove unnecessary else branch 2025-08-17 16:08:38 +02:00
02d84c4d84 code: better debug for install state 2025-08-17 16:07:06 +02:00
ca40a62ff8 clippy/fmt: just fix applied 2025-08-17 16:04:45 +02:00
3dcc0271b8 justfile: typical cargo commands 2025-08-17 16:04:09 +02:00
13 changed files with 5010 additions and 768 deletions

594
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,6 +3,14 @@ name = "lanspread-compat"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"
[lints.rust]
unsafe_code = "forbid"
[lints.clippy]
pedantic = { level = "warn", priority = -1 }
todo = "warn"
unwrap_used = "warn"
[dependencies] [dependencies]
# local # local
lanspread-db = { path = "../lanspread-db" } lanspread-db = { path = "../lanspread-db" }

View File

@@ -58,6 +58,7 @@ impl From<EtiGame> for Game {
max_players: eti_game.game_maxplayers, max_players: eti_game.game_maxplayers,
version: eti_game.game_version, version: eti_game.game_version,
genre: eti_game.genre_de, genre: eti_game.genre_de,
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
size: (eti_game.game_size * 1024.0 * 1024.0 * 1024.0) as u64, size: (eti_game.game_size * 1024.0 * 1024.0 * 1024.0) as u64,
thumbnail: None, thumbnail: None,
installed: false, installed: false,

View File

@@ -3,6 +3,14 @@ name = "lanspread-mdns"
version = "0.1.0" version = "0.1.0"
edition = "2024" edition = "2024"
[lints.rust]
unsafe_code = "forbid"
[lints.clippy]
pedantic = { level = "warn", priority = -1 }
todo = "warn"
unwrap_used = "warn"
[dependencies] [dependencies]
mdns-sd = { workspace = true } mdns-sd = { workspace = true }
eyre = { workspace = true } eyre = { workspace = true }

View File

@@ -1,3 +1,5 @@
#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
use std::net::SocketAddr; use std::net::SocketAddr;
use eyre::bail; use eyre::bail;

View File

@@ -14,6 +14,15 @@ edition = "2024"
name = "lanspread_tauri_deno_ts_lib" name = "lanspread_tauri_deno_ts_lib"
crate-type = ["staticlib", "cdylib", "rlib"] crate-type = ["staticlib", "cdylib", "rlib"]
[lints.rust]
unsafe_code = "forbid"
[lints.clippy]
pedantic = { level = "warn", priority = -1 }
todo = "warn"
unwrap_used = "warn"
needless_pass_by_value = "allow"
[build-dependencies] [build-dependencies]
tauri-build = { version = "2", features = [] } tauri-build = { version = "2", features = [] }

View File

@@ -1,3 +1,3 @@
fn main() { fn main() {
tauri_build::build() tauri_build::build();
} }

View File

@@ -11,7 +11,7 @@ use lanspread_db::db::{Game, GameDB};
use lanspread_mdns::{LANSPREAD_INSTANCE_NAME, LANSPREAD_SERVICE_TYPE, discover_service}; use lanspread_mdns::{LANSPREAD_INSTANCE_NAME, LANSPREAD_SERVICE_TYPE, discover_service};
use tauri::{AppHandle, Emitter as _, Manager}; use tauri::{AppHandle, Emitter as _, Manager};
use tauri_plugin_shell::{ShellExt, process::Command}; use tauri_plugin_shell::{ShellExt, process::Command};
use tokio::sync::{Mutex, RwLock, mpsc::UnboundedSender}; use tokio::sync::{RwLock, mpsc::UnboundedSender};
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/ // Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
@@ -19,7 +19,7 @@ struct LanSpreadState {
server_addr: RwLock<Option<SocketAddr>>, server_addr: RwLock<Option<SocketAddr>>,
client_ctrl: UnboundedSender<ClientCommand>, client_ctrl: UnboundedSender<ClientCommand>,
games: Arc<RwLock<GameDB>>, games: Arc<RwLock<GameDB>>,
games_in_download: Arc<Mutex<HashSet<String>>>, games_in_download: Arc<RwLock<HashSet<String>>>,
games_folder: Arc<RwLock<String>>, games_folder: Arc<RwLock<String>>,
} }
@@ -35,7 +35,7 @@ fn request_games(state: tauri::State<LanSpreadState>) {
#[tauri::command] #[tauri::command]
fn install_game(id: String, state: tauri::State<LanSpreadState>) -> bool { fn install_game(id: String, state: tauri::State<LanSpreadState>) -> bool {
let already_in_download = tauri::async_runtime::block_on(async { let already_in_download = tauri::async_runtime::block_on(async {
if state.inner().games_in_download.lock().await.contains(&id) { if state.inner().games_in_download.read().await.contains(&id) {
log::warn!("Game is already downloading: {id}"); log::warn!("Game is already downloading: {id}");
return true; return true;
} }
@@ -150,18 +150,17 @@ fn run_game(id: String, state: tauri::State<LanSpreadState>) {
} }
fn set_game_install_state_from_path(game_db: &mut GameDB, path: &Path, installed: bool) { fn set_game_install_state_from_path(game_db: &mut GameDB, path: &Path, installed: bool) {
if let Some(file_name) = path.file_name() { if let Some(file_name) = path.file_name()
if let Some(file_name) = file_name.to_str() { && let Some(file_name) = file_name.to_str()
if let Some(game) = game_db.get_mut_game_by_id(file_name) { && let Some(game) = game_db.get_mut_game_by_id(file_name)
{
if installed { if installed {
log::debug!("Game is installed: {game}"); log::debug!("Set {game} to installed");
} else { } else {
log::error!("Game is missing: {game}"); log::debug!("Set {game} to uninstalled");
} }
game.installed = installed; game.installed = installed;
} }
}
}
} }
#[tauri::command] #[tauri::command]
@@ -172,7 +171,7 @@ fn update_game_directory(app_handle: tauri::AppHandle, path: String) {
.state::<LanSpreadState>() .state::<LanSpreadState>()
.client_ctrl .client_ctrl
.send(ClientCommand::SetGameDir(path.clone())) .send(ClientCommand::SetGameDir(path.clone()))
.unwrap(); .expect("Failed to send ClientCommand: SetGameDir");
{ {
tauri::async_runtime::block_on(async { tauri::async_runtime::block_on(async {
@@ -183,13 +182,13 @@ fn update_game_directory(app_handle: tauri::AppHandle, path: String) {
.write() .write()
.await; .await;
*games_folder = path.clone(); games_folder.clone_from(&path);
}); });
} }
let path = PathBuf::from(path); let path = PathBuf::from(path);
if !path.exists() { if !path.exists() {
log::error!("game dir {path:?} does not exist"); log::error!("game dir {} does not exist", path.display());
} }
let entries = match path.read_dir() { let entries = match path.read_dir() {
@@ -213,16 +212,15 @@ fn update_game_directory(app_handle: tauri::AppHandle, path: String) {
// update game_db with installed games from real game directory // update game_db with installed games from real game directory
entries.into_iter().for_each(|entry| { entries.into_iter().for_each(|entry| {
if let Ok(entry) = entry { if let Ok(entry) = entry
if let Ok(path_type) = entry.file_type() { && let Ok(path_type) = entry.file_type()
if path_type.is_dir() { && path_type.is_dir()
{
let path = entry.path(); let path = entry.path();
if path.join("version.ini").exists() { if path.join("version.ini").exists() {
set_game_install_state_from_path(&mut game_db, &path, true); set_game_install_state_from_path(&mut game_db, &path, true);
} }
} }
}
}
}); });
if let Err(e) = app_handle.emit("games-list-updated", Some(game_db.all_games())) { if let Err(e) = app_handle.emit("games-list-updated", Some(game_db.all_games())) {
@@ -243,7 +241,7 @@ async fn find_server(app: AppHandle) {
state state
.client_ctrl .client_ctrl
.send(ClientCommand::ServerAddr(server_addr)) .send(ClientCommand::ServerAddr(server_addr))
.unwrap(); .expect("Failed to send ClientCommand: ServerAddr");
request_games(state); request_games(state);
break; break;
} }
@@ -314,14 +312,11 @@ async fn do_unrar(sidecar: Command, rar_file: &Path, dest_dir: &Path) -> eyre::R
} }
return Ok(()); return Ok(());
} else {
log::error!("dest_dir canonicalize failed: {:?}", &dest_dir);
} }
log::error!("dest_dir canonicalize failed: {}", dest_dir.display());
} else { } else {
log::error!("rar_file canonicalize failed: {:?}", &rar_file); log::error!("rar_file canonicalize failed: {}", rar_file.display());
} }
} else {
log::error!("failed to create dest_dir: {:?}", &dest_dir);
} }
bail!("failed to create directory: {dest_dir:?}"); bail!("failed to create directory: {dest_dir:?}");
@@ -333,10 +328,12 @@ async fn unpack_game(id: &str, sidecar: Command, games_folder: String) {
let local_path = game_path.join("local"); let local_path = game_path.join("local");
if let Err(e) = do_unrar(sidecar, &eti_rar, &local_path).await { if let Err(e) = do_unrar(sidecar, &eti_rar, &local_path).await {
log::error!("{eti_rar:?} -> {local_path:?}: {e}"); log::error!("{} -> {}: {e}", eti_rar.display(), local_path.display());
} }
} }
#[allow(clippy::too_many_lines)]
#[allow(clippy::missing_panics_doc)]
#[cfg_attr(mobile, tauri::mobile_entry_point)] #[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() { pub fn run() {
let tauri_logger_builder = tauri_plugin_log::Builder::new() let tauri_logger_builder = tauri_plugin_log::Builder::new()
@@ -359,8 +356,8 @@ pub fn run() {
server_addr: RwLock::new(None), server_addr: RwLock::new(None),
client_ctrl: tx_client_control, client_ctrl: tx_client_control,
games: Arc::new(RwLock::new(GameDB::empty())), games: Arc::new(RwLock::new(GameDB::empty())),
games_in_download: Arc::new(Mutex::new(HashSet::new())), games_in_download: Arc::new(RwLock::new(HashSet::new())),
games_folder: Arc::new(RwLock::new("".to_string())), games_folder: Arc::new(RwLock::new(String::new())),
}; };
tauri::Builder::default() tauri::Builder::default()
@@ -409,7 +406,7 @@ pub fn run() {
id, id,
file_descriptions, file_descriptions,
}) })
.unwrap(); .expect("Failed to send ClientCommand: DownloadGameFiles");
} }
ClientEvent::DownloadGameFilesBegin { id } => { ClientEvent::DownloadGameFilesBegin { id } => {
@@ -419,7 +416,7 @@ pub fn run() {
.state::<LanSpreadState>() .state::<LanSpreadState>()
.inner() .inner()
.games_in_download .games_in_download
.lock() .write()
.await .await
.insert(id.clone()); .insert(id.clone());
@@ -437,7 +434,7 @@ pub fn run() {
.state::<LanSpreadState>() .state::<LanSpreadState>()
.inner() .inner()
.games_in_download .games_in_download
.lock() .write()
.await .await
.remove(&id.clone()); .remove(&id.clone());
@@ -470,7 +467,7 @@ pub fn run() {
.state::<LanSpreadState>() .state::<LanSpreadState>()
.inner() .inner()
.games_in_download .games_in_download
.lock() .write()
.await .await
.remove(&id.clone()); .remove(&id.clone());
}, },

View File

@@ -7,5 +7,5 @@ use mimalloc::MiMalloc;
static GLOBAL: MiMalloc = MiMalloc; static GLOBAL: MiMalloc = MiMalloc;
fn main() { fn main() {
lanspread_tauri_deno_ts_lib::run() lanspread_tauri_deno_ts_lib::run();
} }

View File

@@ -6,5 +6,17 @@ server:
client: client:
cargo tauri dev cargo tauri dev
fmt:
cargo +nightly fmt
_fix:
cargo fix
cargo clippy --fix
fix: _fix fmt
clippy:
cargo clippy
clean: clean:
cargo clean cargo clean

7
supply-chain/audits.toml Normal file
View File

@@ -0,0 +1,7 @@
# cargo-vet audits file
[[audits.windows-link]]
who = "ddidderr <ddidderr@paul.network>"
criteria = "safe-to-deploy"
delta = "0.1.1 -> 0.1.3"

2184
supply-chain/config.toml Normal file

File diff suppressed because it is too large Load Diff

1982
supply-chain/imports.lock Normal file

File diff suppressed because it is too large Load Diff