Update crates
All checks were successful
build/msvc Build for the target platform: msvc
lint/clippy Checking for common mistakes and opportunities for code improvement
build/linux Build for the target platform: linux

`steamlocate` changed its API again.
`shlex` deprecated `quote`, but that will be addressed later.
This commit is contained in:
Lucas Schwiderski 2024-05-12 20:57:09 +02:00
parent cfee6d9121
commit 86ed5c327f
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8
4 changed files with 608 additions and 506 deletions

1055
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -286,13 +286,19 @@ pub(crate) async fn load_initial(path: PathBuf, is_default: bool) -> Result<Init
let game_info = tokio::task::spawn_blocking(dtmt_shared::collect_game_info)
.await
.wrap_err("Failed to collect Steam game info")?;
.wrap_err("Failed to spawn task to collect Steam game info")?;
let game_info = match game_info {
Ok(game_info) => game_info,
Err(err) => {
tracing::error!("Failed to collect game info: {:?}", err);
None
}
};
{
if config.game_dir.is_none() && game_info.is_none() {
tracing::error!("No Game Directory set. Head to the 'Settings' tab to set it manually",);
}
}
let mod_dir = config.data_dir.join("mods");
let mods = load_mods(mod_dir, config.mod_order.iter())

View file

@ -723,6 +723,14 @@ pub(crate) async fn deploy_mods(state: ActionState) -> Result<()> {
)
.wrap_err("Failed to gather deployment information")?;
let game_info = match game_info {
Ok(game_info) => game_info,
Err(err) => {
tracing::error!("Failed to collect game info: {:#?}", err);
None
}
};
tracing::debug!(?game_info, ?deployment_info);
if let Some(game_info) = game_info {

View file

@ -1,12 +1,15 @@
use std::path::PathBuf;
mod log;
pub use log::*;
use color_eyre::eyre::{OptionExt as _, WrapErr as _};
use color_eyre::Result;
use serde::{Deserialize, Serialize};
use steamlocate::SteamDir;
use time::OffsetDateTime;
pub use log::*;
mod log;
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct ModConfigResources {
pub init: PathBuf,
@ -74,25 +77,23 @@ pub struct GameInfo {
pub last_updated: OffsetDateTime,
}
pub fn collect_game_info() -> Option<GameInfo> {
let mut dir = if let Some(dir) = SteamDir::locate() {
dir
} else {
tracing::debug!("Failed to locate Steam installation");
return None;
};
pub fn collect_game_info() -> Result<Option<GameInfo>> {
let dir = SteamDir::locate().wrap_err("Failed to locate Steam installation")?;
let found = dir
.app(&STEAMAPP_ID)
.and_then(|app| app.last_updated.map(|v| (app.path.clone(), v)));
.find_app(STEAMAPP_ID)
.wrap_err("Failed to look up game by Steam app ID")?;
let Some((path, last_updated)) = found else {
tracing::debug!("Found Steam, but failed to find game installation");
return None;
let Some((app, _)) = found else {
return Ok(None);
};
Some(GameInfo {
path,
let last_updated = app
.last_updated
.ok_or_eyre("Missing field 'last_updated'")?;
Ok(Some(GameInfo {
path: app.install_dir.into(),
last_updated: last_updated.into(),
})
}))
}