import subprocess import os import uuid import shutil from core.config import settings def extract_archive(input_path: str): extract_dir = os.path.join(settings.TEMP_DIR, f"extract_{uuid.uuid4()}") os.makedirs(extract_dir, exist_ok=True) cmd = ["7z", "x", input_path, f"-o{extract_dir}", "-y"] subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return extract_dir def rezip_folder(folder_path: str, target_ext: str): output_name = f"{uuid.uuid4()}.{target_ext}" output_path = os.path.join(settings.OUTPUT_DIR, output_name) cmd = ["7z", "a", output_path, folder_path] subprocess.run(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return output_path