From 6cfd8ae1c20d07d5ffb20715f5844926d9385be3 Mon Sep 17 00:00:00 2001 From: InsanePrawn Date: Tue, 16 Aug 2022 16:38:30 +0200 Subject: [PATCH] flash.py: use exec.file.get_temp_dir() --- flash.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/flash.py b/flash.py index 2e1db83..8e0b1f8 100644 --- a/flash.py +++ b/flash.py @@ -1,11 +1,10 @@ -import atexit import shutil import os import click -import tempfile from constants import FLASH_PARTS, LOCATIONS from exec.cmd import run_root_cmd +from exec.file import get_temp_dir from fastboot import fastboot_flash from image import dd_image, partprobe, shrink_fs, losetup_rootfs_image, dump_aboot, dump_lk2nd, dump_qhypstub, get_device_and_flavour, get_image_name, get_image_path from wrapper import enforce_wrap @@ -58,14 +57,9 @@ def cmd_flash(what: str, location: str): if path == '': raise Exception('Unable to discover Jumpdrive') - minimal_image_dir = tempfile.gettempdir() + minimal_image_dir = get_temp_dir(register_cleanup=True) minimal_image_path = os.path.join(minimal_image_dir, f'minimal-{device_image_name}') - def clean_dir(): - shutil.rmtree(minimal_image_dir) - - atexit.register(clean_dir) - shutil.copyfile(device_image_path, minimal_image_path) loop_device = losetup_rootfs_image(minimal_image_path, sector_size)