fix(dtmm): Fix resetting mods

This commit is contained in:
Lucas Schwiderski 2023-02-28 21:18:32 +01:00
parent d5687ccae4
commit 7c7b9b5890
Signed by: lucas
GPG key ID: AA12679AAA6DF4D8

View file

@ -536,7 +536,8 @@ pub(crate) async fn deploy_mods(state: State) -> Result<()> {
#[tracing::instrument(skip(state))]
pub(crate) async fn reset_mod_deployment(state: State) -> Result<()> {
let paths = [BUNDLE_DATABASE_NAME, BOOT_BUNDLE_NAME];
let boot_bundle_path = format!("{:016x}", Murmur64::hash(BOOT_BUNDLE_NAME.as_bytes()));
let paths = [BUNDLE_DATABASE_NAME, &boot_bundle_path];
let bundle_dir = state.game_dir.join("bundle");
tracing::info!("Resetting mod deployment in {}", bundle_dir.display());
@ -545,6 +546,7 @@ pub(crate) async fn reset_mod_deployment(state: State) -> Result<()> {
let path = bundle_dir.join(p);
let backup = bundle_dir.join(&format!("{}.bak", p));
let res = async {
tracing::debug!(
"Copying from backup: {} -> {}",
backup.display(),
@ -553,14 +555,26 @@ pub(crate) async fn reset_mod_deployment(state: State) -> Result<()> {
fs::copy(&backup, &path)
.await
.wrap_err_with(|| format!("failed to '{}' restore from backup", p))?;
.wrap_err_with(|| format!("failed to copy from '{}'", backup.display()))?;
tracing::debug!("Deleting backup: {}", backup.display(),);
tracing::debug!("Deleting backup: {}", backup.display());
fs::remove_file(&backup)
.await
.wrap_err_with(|| format!("failed to remove backup '{}'", p))?;
.wrap_err_with(|| format!("failed to remove '{}'", backup.display()))
}
.await;
if let Err(err) = res {
tracing::error!(
"Failed to restore '{}' from backup. You may need to verify game files. Error: {:?}",
&p,
err
);
}
}
tracing::info!("Reset finished");
Ok(())
}