From f5f4239337acde805c8fe59016d01616321cdd48 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Thu, 26 Oct 2023 12:14:09 +0200 Subject: [PATCH] Delete files associated to VM --- virtweb_backend/src/actors/libvirt_actor.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/virtweb_backend/src/actors/libvirt_actor.rs b/virtweb_backend/src/actors/libvirt_actor.rs index 6a782e2..13cf627 100644 --- a/virtweb_backend/src/actors/libvirt_actor.rs +++ b/virtweb_backend/src/actors/libvirt_actor.rs @@ -148,7 +148,14 @@ impl Handler for LibVirtActor { false => sys::VIR_DOMAIN_UNDEFINE_NVRAM, })?; - // TODO : delete files, if requested + if !msg.keep_files { + log::info!("Delete storage associated with the domain"); + let path = AppConfig::get().vm_storage_path(msg.id); + if path.exists() { + std::fs::remove_dir_all(path)?; + } + } + Ok(()) } }