Skip to content

Commit

Permalink
Merge pull request #10 from AdastralGroup/develop
Browse files Browse the repository at this point in the history
v1.4.2 - Bug Fixes
  • Loading branch information
ktwrd authored Jun 11, 2024
2 parents d018c61 + c5199da commit 4a83444
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "beans-rs"
version = "1.4.1"
version = "1.4.2"
edition = "2021"
authors = [
"Adastral Group (https://adastral.net)",
Expand Down
21 changes: 19 additions & 2 deletions src/helper/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ use std::path::PathBuf;
use indicatif::{ProgressBar, ProgressStyle};
use futures::StreamExt;
use futures_util::SinkExt;

Check warning on line 18 in src/helper/mod.rs

View workflow job for this annotation

GitHub Actions / release ubuntu-latest

unused import: `futures_util::SinkExt`

Check warning on line 18 in src/helper/mod.rs

View workflow job for this annotation

GitHub Actions / release windows-latest

unused import: `futures_util::SinkExt`
use log::{debug, trace};
use crate::{BeansError, DownloadFailureReason};
use log::{debug, error, trace};
use crate::{BeansError, DownloadFailureReason, RunnerContext};
use rand::{distributions::Alphanumeric, Rng};
use reqwest::header::USER_AGENT;
use crate::version::RemoteVersionResponse;

Check warning on line 23 in src/helper/mod.rs

View workflow job for this annotation

GitHub Actions / release ubuntu-latest

unused import: `crate::version::RemoteVersionResponse`

Check warning on line 23 in src/helper/mod.rs

View workflow job for this annotation

GitHub Actions / release windows-latest

unused import: `crate::version::RemoteVersionResponse`
Expand Down Expand Up @@ -400,6 +400,23 @@ pub async fn beans_has_update() -> Result<Option<GithubReleaseItem>, BeansError>
}
return Ok(None);
}
pub fn restore_gameinfo(ctx: &mut RunnerContext, data: Vec<u8>) -> Result<(), BeansError> {
let loc = ctx.gameinfo_location();
trace!("gameinfo location: {}", &loc);
if let Ok(m) = std::fs::metadata(&loc) {
trace!("gameinfo metadata: {:#?}", m);
}
if let Err(e) = std::fs::write(&loc, data) {
trace!("error: {:#?}", e);
error!("[UpdateWorkflow::wizard] Failed to write gameinfo.txt backup {:}", e);
}
if let Err(e) = ctx.gameinfo_perms() {
error!("[UpdateWorkflow::wizard] Failed to update permissions on gameinfo.txt {:}", e);
sentry::capture_error(&e);
return Err(e);
}
return Ok(());
}
const GITHUB_RELEASES_URL: &str = "https://api.github.com/repos/adastralgroup/beans-rs/releases/latest";
#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]
pub struct GithubReleaseItem
Expand Down
16 changes: 2 additions & 14 deletions src/workflows/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,9 @@ impl UpdateWorkflow
return Err(e);
}

ctx.gameinfo_perms()?;
if let Some(gi) = gameinfo_backup {
let loc = ctx.gameinfo_location();
trace!("gameinfo location: {}", &loc);
if let Ok(m) = std::fs::metadata(&loc) {
trace!("gameinfo metadata: {:#?}", m);
}
if let Err(e) = std::fs::write(&loc, gi) {
trace!("error: {:#?}", e);
error!("[UpdateWorkflow::wizard] Failed to write gameinfo.txt backup {:}", e);
}
if let Err(e) = ctx.gameinfo_perms() {
error!("[UpdateWorkflow::wizard] Failed to update permissions on gameinfo.txt {:}", e);
sentry::capture_error(&e);
return Err(e);
}
helper::restore_gameinfo(ctx, gi)?;
}

println!("Game has been updated!");
Expand Down
8 changes: 7 additions & 1 deletion src/workflows/verify.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{BeansError, butler, RunnerContext};
use crate::{BeansError, butler, helper, RunnerContext};
use crate::version::RemoteVersion;

pub struct VerifyWorkflow {
Expand Down Expand Up @@ -29,11 +29,17 @@ impl VerifyWorkflow {
return Ok(());
}

ctx.gameinfo_perms()?;
let gameinfo_backup = ctx.read_gameinfo_file()?;
let mod_dir_location = ctx.get_mod_location();
butler::verify(
format!("{}{}", &av.remote_info.base_url, remote.signature_url.unwrap()),
mod_dir_location.clone(),
format!("{}{}", &av.remote_info.base_url, remote.heal_url.unwrap()))?;
ctx.gameinfo_perms()?;
if let Some(gi) = gameinfo_backup {
helper::restore_gameinfo(ctx, gi)?;
}
println!("[VerifyWorkflow::wizard] The verification process has completed, and any corruption has been repaired.");
Ok(())
}
Expand Down

0 comments on commit 4a83444

Please sign in to comment.