From 89a4e3995ff88e0c5cae8f0399c3cbcbec88bed8 Mon Sep 17 00:00:00 2001 From: asonix Date: Sat, 23 Dec 2023 12:10:25 -0600 Subject: [PATCH] Add warn logs when performing blocking removes due to dropped files --- src/tmp_file.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/tmp_file.rs b/src/tmp_file.rs index 81eda3c..46e9c14 100644 --- a/src/tmp_file.rs +++ b/src/tmp_file.rs @@ -57,7 +57,8 @@ impl TmpDir { impl Drop for TmpDir { fn drop(&mut self) { - if let Some(path) = self.path.as_ref() { + if let Some(path) = self.path.take() { + tracing::warn!("TmpDir - Blocking remove of {path:?}"); std::fs::remove_dir_all(path).expect("Removed directory"); } } @@ -98,7 +99,10 @@ impl Deref for TmpFolder { impl Drop for TmpFolder { fn drop(&mut self) { if let Some(path) = self.0.take() { - let _ = std::fs::remove_dir_all(path); + tracing::warn!("TmpFolder - Blocking remove of directory {path:?}"); + if let Err(e) = std::fs::remove_dir_all(path) { + tracing::error!("Failed removing directory {e}"); + } } } } @@ -138,7 +142,10 @@ impl Deref for TmpFile { impl Drop for TmpFile { fn drop(&mut self) { if let Some(path) = self.0.take() { - let _ = std::fs::remove_file(path); + tracing::warn!("TmpFile - Blocking remove of file {path:?}"); + if let Err(e) = std::fs::remove_file(path) { + tracing::error!("Failed removing file {e}"); + } } } }