fix: auto-cleanup staging files to minimize disk usage
Deletes intermediate files as conversion progresses: - Archive (.7z/.zip) after extraction - Source VMDK after qemu-img convert - Local QCOW2 after qm disk import Reduces peak storage from zip+VMDK+QCOW2 to just the largest single file — critical for the 94 GB rootfs with 87 GB images.
This commit is contained in:
parent
a7ab9243c0
commit
b33ab1605e
1 changed files with 24 additions and 0 deletions
|
|
@ -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")
|
||||
|
|
|
|||
Loading…
Reference in a new issue