diff --git a/backend/provisioner.py b/backend/provisioner.py index 80cb50f..2fc5cbf 100644 --- a/backend/provisioner.py +++ b/backend/provisioner.py @@ -259,11 +259,27 @@ def _process_job(job_id: str, req: JobSubmissionRequest): logger.info("Disk %d: source=%s format=%s size=%.1f GiB", idx, source_path, disk.format, disk.size_gb) + # Delete archive after extraction to free space + if src_path.exists() and src_path != source and src_path.is_file(): + try: + src_path.unlink() + logger.info("Deleted archive: %s", src_path) + except Exception: + pass + # Convert with real-time progress _convert_with_progress( job_id, source_path, output_path, disk.format, start_pct=10 + idx * 10, end_pct=55 + idx * 10, ) + + # Delete source VMDK after conversion to free space + if source_path.exists() and source_path != src_path: + try: + source_path.unlink() + logger.info("Deleted source disk: %s", source_path) + except Exception: + pass else: size_gb = spec.size_gb or 32 logger.info("Creating empty disk %d: %d GiB", idx, size_gb) @@ -378,6 +394,14 @@ def _process_job(job_id: str, req: JobSubmissionRequest): _update_job(job_id, progress=75 + idx * 10, message=f"Imported disk {idx + 1}/{len(disk_paths)}") + # Delete local QCOW2 after import to free space + if disk_path.exists(): + try: + disk_path.unlink() + logger.info("Deleted local QCOW2: %s", disk_path) + except Exception: + pass + # ── Add EFI disk if UEFI ────────────────────────────────── if final_boot.value == "uefi": logger.info("Adding EFI disk")