From 1fa253dfff7df87101bd4bba0695239590ed0a02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=E1=BA=BF=20H=C6=B0ng?= Date: Thu, 12 Mar 2026 20:19:29 +0700 Subject: [PATCH] chore: remove dir before extract --- apps/nginx/module-installer.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/nginx/module-installer.py b/apps/nginx/module-installer.py index a572d7e..0d2de38 100644 --- a/apps/nginx/module-installer.py +++ b/apps/nginx/module-installer.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 import json +import shutil import subprocess import sys from pathlib import Path @@ -38,9 +39,12 @@ def download_and_unpack(url: str) -> str: print(f"File '{file_name}' already exists. Skipping download.") else: subprocess.call(["wget", url]) + file_name_without_ext = file_name.rsplit(".", 2)[0] # Remove .tar.gz + shutil.rmtree( + file_name_without_ext, ignore_errors=True + ) # Remove existing dir if exists print("Unpacking...") subprocess.call(["tar", "zxvf", file_name]) - file_name_without_ext = file_name.rsplit(".", 2)[0] # Remove .tar.gz print(f"Download and unpack complete: {file_name} to {file_name_without_ext}") return file_name_without_ext