Harden atomic rename

This commit is contained in:
Henrik Brüsecke 2026-11-07 13:04:20 +02:00
parent 98840ead3b
commit c385a100a3
2 changed files with 2 additions and 6 deletions

View file

@ -4,7 +4,7 @@ import subprocess
import tempfile
def create_os_disk(paths):
with tempfile.TemporaryDirectory(dir=paths.staging_path) as temporary_directory:
with tempfile.TemporaryDirectory(dir=paths.target_path.parent) as temporary_directory:
temporary_path = pathlib.Path(temporary_directory) / 'disk.qcow2'
subprocess.run(
@ -22,7 +22,7 @@ def create_os_disk(paths):
temporary_path.replace(paths.target_path)
def create_nvram_disk(paths):
with tempfile.TemporaryDirectory(dir=paths.staging_path) as temporary_directory:
with tempfile.TemporaryDirectory(dir=paths.nvram_target_path.parent) as temporary_directory:
temporary_path = pathlib.Path(temporary_directory) / 'NVRAM.img'
shutil.copyfile(paths.nvram_path, temporary_path)