From fe3de0715786c7cb991b72be3a34aeb29a7de083 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Fri, 19 Sep 2025 08:41:24 +0200 Subject: [PATCH] Add clean install option to fetch_and_deploy_gh_release Introduces a CLEAN_INSTALL environment variable to optionally remove all files in the target directory before extracting a GitHub release. This ensures a clean deployment when required. --- misc/tools.func | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/misc/tools.func b/misc/tools.func index 381fe85a..88950d69 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -858,6 +858,9 @@ function fetch_and_deploy_gh_release() { msg_info "Fetching GitHub release: $app ($version)" + local clean_install=false + [[ -n "${CLEAN_INSTALL:-}" && "$CLEAN_INSTALL" == "1" ]] && clean_install=true + ### Tarball Mode ### if [[ "$mode" == "tarball" || "$mode" == "source" ]]; then url=$(echo "$json" | jq -r '.tarball_url // empty') @@ -871,6 +874,10 @@ function fetch_and_deploy_gh_release() { } mkdir -p "$target" + if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then + rm -rf "${target:?}/"* + fi + tar -xzf "$tmpdir/$filename" -C "$tmpdir" local unpack_dir unpack_dir=$(find "$tmpdir" -mindepth 1 -maxdepth 1 -type d | head -n1) @@ -940,7 +947,7 @@ function fetch_and_deploy_gh_release() { } } - ### Prebuild Mode ### + ### Prebuild Mode ### elif [[ "$mode" == "prebuild" ]]; then local pattern="${6%\"}" pattern="${pattern#\"}" @@ -977,6 +984,9 @@ function fetch_and_deploy_gh_release() { local unpack_tmp unpack_tmp=$(mktemp -d) mkdir -p "$target" + if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then + rm -rf "${target:?}/"* + fi if [[ "$filename" == *.zip ]]; then if ! command -v unzip &>/dev/null; then