Skip to content

Commit 5cc9d68

Browse files
committed
chore(external-ssh-signer): add cleanup of temp key file
1 parent c8de875 commit 5cc9d68

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Diff for: asyncgit/src/sync/sign.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,13 @@ impl Sign for SSHSign {
323323
.wait_with_output()
324324
.map_err(|e| SignError::Output(e.to_string()))?;
325325

326-
//TODO: cleanup temp file if created
326+
let tmp_path = std::env::temp_dir();
327+
if self.signing_key.starts_with(tmp_path) {
328+
// Not handling error, as its not that bad. OS maintenance tasks will take care of it at a later point.
329+
let _ = std::fs::remove_file(PathBuf::from(
330+
&self.signing_key,
331+
));
332+
}
327333

328334
if !output.status.success() {
329335
return Err(SignError::Shellout(format!(

0 commit comments

Comments
 (0)