From d5e0f7c64e1610968e8218fd84a67e07f27faf82 Mon Sep 17 00:00:00 2001 From: phoenix Date: Sat, 11 Oct 2025 18:09:50 -0400 Subject: [PATCH] Added method to remove file from the filesystem --- src/coverart.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/coverart.rs b/src/coverart.rs index 5444a3e..6b7a782 100644 --- a/src/coverart.rs +++ b/src/coverart.rs @@ -39,7 +39,18 @@ impl CoverArt { } } - // TODO: Add method to remove from filesystem + /// Removes the coverart from the filesystem + pub fn remove_from_filesystem(&self) -> Result<(), std::io::Error> { + let p = std::path::Path::new(&self.path); + if p.exists() { + match std::fs::remove_file(p) { + Ok(_) => Ok(()), + Err(err) => Err(err), + } + } else { + Err(std::io::Error::other("Cannot delete file that does not exist")) + } + } } pub mod io {