Skip to content

Commit 6740fa6

Browse files
authored
Merge pull request #56 from Pre-Fortress-2/butler-cleanup
feat: clean up command also removes butler-staging
2 parents a1a363d + c286bbe commit 6740fa6

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/workflows/clean.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ pub struct CleanWorkflow
1414

1515
impl CleanWorkflow
1616
{
17-
pub fn wizard(_ctx: &mut RunnerContext) -> Result<(), BeansError>
17+
pub fn wizard(ctx: &mut RunnerContext) -> Result<(), BeansError>
1818
{
1919
let target_directory = helper::get_tmp_dir();
20+
let staging_dir_location = ctx.get_staging_location();
2021

2122
info!("[CleanWorkflow] Cleaning up {}", target_directory);
2223
if !helper::file_exists(target_directory.clone())
@@ -46,6 +47,24 @@ impl CleanWorkflow
4647
});
4748
}
4849

50+
// clean up butler files if it was interrupted in previous install
51+
if !helper::file_exists(staging_dir_location.clone())
52+
{
53+
debug!("[CleanWorkflow] Staging directory used by butler not found, nothing to clean.")
54+
} else {
55+
// delete temp butler directory and it's contents (and error handling)
56+
info!("[CleanWorkflow] Cleaning up {}", staging_dir_location);
57+
if let Err(e) = std::fs::remove_dir_all(&staging_dir_location)
58+
{
59+
debug!("[CleanWorkflow::wizard] remove_dir_all {:#?}", e);
60+
return Err(BeansError::CleanTempFailure {
61+
location: staging_dir_location,
62+
error: e,
63+
backtrace: std::backtrace::Backtrace::capture()
64+
});
65+
}
66+
}
67+
4968
info!("[CleanWorkflow] Done!");
5069
Ok(())
5170
}

0 commit comments

Comments
 (0)