diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-09-01 17:55:51 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-09-01 17:55:51 +0300 |
commit | b81a6a6c2843a4cf590bceafbad619519ea6adce (patch) | |
tree | 955f95f60ec1b341649755358dc7e99a4470e783 | |
parent | 5451455dce252638d51ccbea204f749b36144af3 (diff) | |
download | vmadm-b81a6a6c2843a4cf590bceafbad619519ea6adce.tar.gz |
fix: include filename in error message of being unable to rm image
Sponsored-by: author
-rw-r--r-- | src/libvirt.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/libvirt.rs b/src/libvirt.rs index 403dc45..c262444 100644 --- a/src/libvirt.rs +++ b/src/libvirt.rs @@ -2,7 +2,7 @@ use crate::util::wait_for_ssh; use log::debug; -use std::path::Path; +use std::path::{Path, PathBuf}; use std::thread; use std::time::Duration; use virt::connect::Connect; @@ -52,6 +52,10 @@ pub enum VirtError { #[error("couldn't set domain {0} to be autostarted")] Autostart(String, #[source] virt::error::Error), + /// Failed to delete image file. + #[error("failed to delete image file {0}")] + DeleteImage(PathBuf, #[source] std::io::Error), + /// Error doing I/O. #[error(transparent)] IoError(#[from] std::io::Error), @@ -175,7 +179,8 @@ impl Libvirt { .map_err(|err| VirtError::Undefine(name.to_string(), err))?; debug!("removing image file {}", image.display()); - std::fs::remove_file(image)?; + std::fs::remove_file(image) + .map_err(|e| VirtError::DeleteImage(image.to_path_buf(), e))?; } Ok(()) |