2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-12-22 11:21:24 +00:00

Add warn logs when performing blocking removes due to dropped files

This commit is contained in:
asonix 2023-12-23 12:10:25 -06:00
parent 6fa79b9188
commit 89a4e3995f

View file

@ -57,7 +57,8 @@ impl TmpDir {
impl Drop for TmpDir { impl Drop for TmpDir {
fn drop(&mut self) { 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"); std::fs::remove_dir_all(path).expect("Removed directory");
} }
} }
@ -98,7 +99,10 @@ impl Deref for TmpFolder {
impl Drop for TmpFolder { impl Drop for TmpFolder {
fn drop(&mut self) { fn drop(&mut self) {
if let Some(path) = self.0.take() { 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 { impl Drop for TmpFile {
fn drop(&mut self) { fn drop(&mut self) {
if let Some(path) = self.0.take() { 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}");
}
} }
} }
} }