Compare commits
11 Commits
98126a72da
...
main
Author | SHA1 | Date | |
---|---|---|---|
ac11f91d79
|
|||
8e76e8d1e2
|
|||
3b6fc80578
|
|||
8c6fd139c8
|
|||
66572e16ce
|
|||
3b19cb8b18
|
|||
61a41c7122
|
|||
cbad9389ee
|
|||
02d84c4d84
|
|||
ca40a62ff8
|
|||
3dcc0271b8
|
594
Cargo.lock
generated
594
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -3,6 +3,14 @@ name = "lanspread-compat"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lints.rust]
|
||||
unsafe_code = "forbid"
|
||||
|
||||
[lints.clippy]
|
||||
pedantic = { level = "warn", priority = -1 }
|
||||
todo = "warn"
|
||||
unwrap_used = "warn"
|
||||
|
||||
[dependencies]
|
||||
# local
|
||||
lanspread-db = { path = "../lanspread-db" }
|
||||
|
@@ -58,6 +58,7 @@ impl From<EtiGame> for Game {
|
||||
max_players: eti_game.game_maxplayers,
|
||||
version: eti_game.game_version,
|
||||
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,
|
||||
thumbnail: None,
|
||||
installed: false,
|
||||
|
@@ -3,6 +3,14 @@ name = "lanspread-mdns"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[lints.rust]
|
||||
unsafe_code = "forbid"
|
||||
|
||||
[lints.clippy]
|
||||
pedantic = { level = "warn", priority = -1 }
|
||||
todo = "warn"
|
||||
unwrap_used = "warn"
|
||||
|
||||
[dependencies]
|
||||
mdns-sd = { workspace = true }
|
||||
eyre = { workspace = true }
|
||||
|
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::missing_errors_doc, clippy::missing_panics_doc)]
|
||||
|
||||
use std::net::SocketAddr;
|
||||
|
||||
use eyre::bail;
|
||||
|
@@ -14,6 +14,15 @@ edition = "2024"
|
||||
name = "lanspread_tauri_deno_ts_lib"
|
||||
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]
|
||||
tauri-build = { version = "2", features = [] }
|
||||
|
||||
|
@@ -1,3 +1,3 @@
|
||||
fn main() {
|
||||
tauri_build::build()
|
||||
tauri_build::build();
|
||||
}
|
||||
|
@@ -11,7 +11,7 @@ use lanspread_db::db::{Game, GameDB};
|
||||
use lanspread_mdns::{LANSPREAD_INSTANCE_NAME, LANSPREAD_SERVICE_TYPE, discover_service};
|
||||
use tauri::{AppHandle, Emitter as _, Manager};
|
||||
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/
|
||||
|
||||
@@ -19,7 +19,7 @@ struct LanSpreadState {
|
||||
server_addr: RwLock<Option<SocketAddr>>,
|
||||
client_ctrl: UnboundedSender<ClientCommand>,
|
||||
games: Arc<RwLock<GameDB>>,
|
||||
games_in_download: Arc<Mutex<HashSet<String>>>,
|
||||
games_in_download: Arc<RwLock<HashSet<String>>>,
|
||||
games_folder: Arc<RwLock<String>>,
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ fn request_games(state: tauri::State<LanSpreadState>) {
|
||||
#[tauri::command]
|
||||
fn install_game(id: String, state: tauri::State<LanSpreadState>) -> bool {
|
||||
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}");
|
||||
return true;
|
||||
}
|
||||
@@ -150,17 +150,16 @@ fn run_game(id: String, state: tauri::State<LanSpreadState>) {
|
||||
}
|
||||
|
||||
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) = file_name.to_str() {
|
||||
if let Some(game) = game_db.get_mut_game_by_id(file_name) {
|
||||
if installed {
|
||||
log::debug!("Game is installed: {game}");
|
||||
} else {
|
||||
log::error!("Game is missing: {game}");
|
||||
}
|
||||
game.installed = installed;
|
||||
}
|
||||
if let Some(file_name) = path.file_name()
|
||||
&& let Some(file_name) = file_name.to_str()
|
||||
&& let Some(game) = game_db.get_mut_game_by_id(file_name)
|
||||
{
|
||||
if installed {
|
||||
log::debug!("Set {game} to installed");
|
||||
} else {
|
||||
log::debug!("Set {game} to uninstalled");
|
||||
}
|
||||
game.installed = installed;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,7 +171,7 @@ fn update_game_directory(app_handle: tauri::AppHandle, path: String) {
|
||||
.state::<LanSpreadState>()
|
||||
.client_ctrl
|
||||
.send(ClientCommand::SetGameDir(path.clone()))
|
||||
.unwrap();
|
||||
.expect("Failed to send ClientCommand: SetGameDir");
|
||||
|
||||
{
|
||||
tauri::async_runtime::block_on(async {
|
||||
@@ -183,13 +182,13 @@ fn update_game_directory(app_handle: tauri::AppHandle, path: String) {
|
||||
.write()
|
||||
.await;
|
||||
|
||||
*games_folder = path.clone();
|
||||
games_folder.clone_from(&path);
|
||||
});
|
||||
}
|
||||
|
||||
let path = PathBuf::from(path);
|
||||
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() {
|
||||
@@ -213,14 +212,13 @@ fn update_game_directory(app_handle: tauri::AppHandle, path: String) {
|
||||
|
||||
// update game_db with installed games from real game directory
|
||||
entries.into_iter().for_each(|entry| {
|
||||
if let Ok(entry) = entry {
|
||||
if let Ok(path_type) = entry.file_type() {
|
||||
if path_type.is_dir() {
|
||||
let path = entry.path();
|
||||
if path.join("version.ini").exists() {
|
||||
set_game_install_state_from_path(&mut game_db, &path, true);
|
||||
}
|
||||
}
|
||||
if let Ok(entry) = entry
|
||||
&& let Ok(path_type) = entry.file_type()
|
||||
&& path_type.is_dir()
|
||||
{
|
||||
let path = entry.path();
|
||||
if path.join("version.ini").exists() {
|
||||
set_game_install_state_from_path(&mut game_db, &path, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -243,7 +241,7 @@ async fn find_server(app: AppHandle) {
|
||||
state
|
||||
.client_ctrl
|
||||
.send(ClientCommand::ServerAddr(server_addr))
|
||||
.unwrap();
|
||||
.expect("Failed to send ClientCommand: ServerAddr");
|
||||
request_games(state);
|
||||
break;
|
||||
}
|
||||
@@ -314,14 +312,11 @@ async fn do_unrar(sidecar: Command, rar_file: &Path, dest_dir: &Path) -> eyre::R
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
} else {
|
||||
log::error!("dest_dir canonicalize failed: {:?}", &dest_dir);
|
||||
}
|
||||
log::error!("dest_dir canonicalize failed: {}", dest_dir.display());
|
||||
} 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:?}");
|
||||
@@ -333,10 +328,12 @@ async fn unpack_game(id: &str, sidecar: Command, games_folder: String) {
|
||||
let local_path = game_path.join("local");
|
||||
|
||||
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)]
|
||||
pub fn run() {
|
||||
let tauri_logger_builder = tauri_plugin_log::Builder::new()
|
||||
@@ -359,8 +356,8 @@ pub fn run() {
|
||||
server_addr: RwLock::new(None),
|
||||
client_ctrl: tx_client_control,
|
||||
games: Arc::new(RwLock::new(GameDB::empty())),
|
||||
games_in_download: Arc::new(Mutex::new(HashSet::new())),
|
||||
games_folder: Arc::new(RwLock::new("".to_string())),
|
||||
games_in_download: Arc::new(RwLock::new(HashSet::new())),
|
||||
games_folder: Arc::new(RwLock::new(String::new())),
|
||||
};
|
||||
|
||||
tauri::Builder::default()
|
||||
@@ -409,7 +406,7 @@ pub fn run() {
|
||||
id,
|
||||
file_descriptions,
|
||||
})
|
||||
.unwrap();
|
||||
.expect("Failed to send ClientCommand: DownloadGameFiles");
|
||||
|
||||
}
|
||||
ClientEvent::DownloadGameFilesBegin { id } => {
|
||||
@@ -419,7 +416,7 @@ pub fn run() {
|
||||
.state::<LanSpreadState>()
|
||||
.inner()
|
||||
.games_in_download
|
||||
.lock()
|
||||
.write()
|
||||
.await
|
||||
.insert(id.clone());
|
||||
|
||||
@@ -437,7 +434,7 @@ pub fn run() {
|
||||
.state::<LanSpreadState>()
|
||||
.inner()
|
||||
.games_in_download
|
||||
.lock()
|
||||
.write()
|
||||
.await
|
||||
.remove(&id.clone());
|
||||
|
||||
@@ -470,7 +467,7 @@ pub fn run() {
|
||||
.state::<LanSpreadState>()
|
||||
.inner()
|
||||
.games_in_download
|
||||
.lock()
|
||||
.write()
|
||||
.await
|
||||
.remove(&id.clone());
|
||||
},
|
||||
|
@@ -7,5 +7,5 @@ use mimalloc::MiMalloc;
|
||||
static GLOBAL: MiMalloc = MiMalloc;
|
||||
|
||||
fn main() {
|
||||
lanspread_tauri_deno_ts_lib::run()
|
||||
lanspread_tauri_deno_ts_lib::run();
|
||||
}
|
||||
|
12
justfile
12
justfile
@@ -6,5 +6,17 @@ server:
|
||||
client:
|
||||
cargo tauri dev
|
||||
|
||||
fmt:
|
||||
cargo +nightly fmt
|
||||
|
||||
_fix:
|
||||
cargo fix
|
||||
cargo clippy --fix
|
||||
|
||||
fix: _fix fmt
|
||||
|
||||
clippy:
|
||||
cargo clippy
|
||||
|
||||
clean:
|
||||
cargo clean
|
||||
|
7
supply-chain/audits.toml
Normal file
7
supply-chain/audits.toml
Normal 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
2184
supply-chain/config.toml
Normal file
File diff suppressed because it is too large
Load Diff
1982
supply-chain/imports.lock
Normal file
1982
supply-chain/imports.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user