diff --git a/judge_control_app/src/custom_rc/readonly_file.rs b/judge_control_app/src/custom_rc/readonly_file.rs index 61e2d2d..68bb5aa 100644 --- a/judge_control_app/src/custom_rc/readonly_file.rs +++ b/judge_control_app/src/custom_rc/readonly_file.rs @@ -27,6 +27,20 @@ impl ReadonlyFile { } } +impl Drop for ReadonlyFile { + fn drop(&mut self) { + let result = std::fs::remove_file(&self.path).context(format!( + "Failed to remove file while dropping ReadonlyFile : {:?}", + self.path + )); + match result { + Ok(_) => {} + Err(e) => { + eprintln!("{:?}", e); + } + } + } +} impl super::File for ReadonlyFile { fn path(&self) -> PathBuf { self.path.clone()