fix: /tmp no longer clogged by random leftover mods (#82)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
VERSION="0.6.7"
|
|
||||||
|
VERSION="0.6.8"
|
||||||
|
|
||||||
# --- Globals ---
|
# --- Globals ---
|
||||||
|
|
||||||
@@ -590,6 +591,7 @@ function mod_enable() {
|
|||||||
|
|
||||||
# move files to a temp directory that has the same name as the mod
|
# move files to a temp directory that has the same name as the mod
|
||||||
temp_dir=$(mktemp -d)
|
temp_dir=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$temp_dir"' EXIT
|
||||||
[[ ! -d "$temp_dir" ]] && { log ERROR "Could not create temporary directory."; exit 1; }
|
[[ ! -d "$temp_dir" ]] && { log ERROR "Could not create temporary directory."; exit 1; }
|
||||||
|
|
||||||
for file in $current_mod_files; do
|
for file in $current_mod_files; do
|
||||||
@@ -797,7 +799,9 @@ function mod_install() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# mod_dir as a temporary directory
|
# mod_dir as a temporary directory
|
||||||
mod_dir+=$(mktemp -d)
|
temp_folder=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$temp_folder"' EXIT
|
||||||
|
mod_dir+=("$temp_folder")
|
||||||
if [[ $is_not_zip == true ]]; then
|
if [[ $is_not_zip == true ]]; then
|
||||||
unar -q "$mod_zip" -o "$mod_dir"
|
unar -q "$mod_zip" -o "$mod_dir"
|
||||||
else
|
else
|
||||||
@@ -805,6 +809,11 @@ function mod_install() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ $has_nexus_mod_arguments == true ]]; then
|
||||||
|
# overwrite trap in case of nexus mod
|
||||||
|
trap 'read -p "Press Enter to continue..."; rm -rf "$output_folder"; rm -rf "$temp_folder"' EXIT
|
||||||
|
fi
|
||||||
|
|
||||||
# if there's more than 1 directory, call recursively
|
# if there's more than 1 directory, call recursively
|
||||||
while [[ ${#mod_dir[@]} -gt 1 ]]; do
|
while [[ ${#mod_dir[@]} -gt 1 ]]; do
|
||||||
mod_install "${mod_dir[0]}"
|
mod_install "${mod_dir[0]}"
|
||||||
@@ -1068,6 +1077,7 @@ function mod_export() {
|
|||||||
if [[ $modpack_export == true || "$confirm" == "y" || "$confirm" == "Y" || "$confirm" = "" ]]; then
|
if [[ $modpack_export == true || "$confirm" == "y" || "$confirm" == "Y" || "$confirm" = "" ]]; then
|
||||||
# create a temporary directory to store the mods
|
# create a temporary directory to store the mods
|
||||||
OUT_DIR=$(mktemp -d)
|
OUT_DIR=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$OUT_DIR"' EXIT
|
||||||
MODS_EXPORT_DIR="$OUT_DIR/Helldivers 2 Mods"
|
MODS_EXPORT_DIR="$OUT_DIR/Helldivers 2 Mods"
|
||||||
mkdir -p "$MODS_EXPORT_DIR"
|
mkdir -p "$MODS_EXPORT_DIR"
|
||||||
cp "$DB_FILE" "$MODS_EXPORT_DIR"
|
cp "$DB_FILE" "$MODS_EXPORT_DIR"
|
||||||
@@ -1109,6 +1119,7 @@ function mod_import() {
|
|||||||
|
|
||||||
# extract in temp directory
|
# extract in temp directory
|
||||||
OUT_DIR=$(mktemp -d)
|
OUT_DIR=$(mktemp -d)
|
||||||
|
trap 'rm -rf "$OUT_DIR"' EXIT
|
||||||
tar -xzf "$1" -C "$OUT_DIR"
|
tar -xzf "$1" -C "$OUT_DIR"
|
||||||
[[ $? -ne 0 ]] && { log ERROR "Could not import mods. Possibly because the archive is invalid."; exit 1; }
|
[[ $? -ne 0 ]] && { log ERROR "Could not import mods. Possibly because the archive is invalid."; exit 1; }
|
||||||
|
|
||||||
@@ -1451,6 +1462,7 @@ function modpack_create() {
|
|||||||
# overwrite all paths to create a custom directory that will hold the mods specified, the mods will be "installed" there
|
# overwrite all paths to create a custom directory that will hold the mods specified, the mods will be "installed" there
|
||||||
OLD_MODS_DIR="$MODS_DIR"
|
OLD_MODS_DIR="$MODS_DIR"
|
||||||
MODS_DIR="$(mktemp -d)"
|
MODS_DIR="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$MODS_DIR"' EXIT
|
||||||
DB_FILE="$MODS_DIR/mods.csv"
|
DB_FILE="$MODS_DIR/mods.csv"
|
||||||
echo "$(get_version_major)" > "$DB_FILE"
|
echo "$(get_version_major)" > "$DB_FILE"
|
||||||
|
|
||||||
@@ -1786,7 +1798,9 @@ function nexus() {
|
|||||||
|
|
||||||
# extract file name
|
# extract file name
|
||||||
file_name=$(echo "$download_url" | awk -F/ '{print $6}' | cut -d\? -f1)
|
file_name=$(echo "$download_url" | awk -F/ '{print $6}' | cut -d\? -f1)
|
||||||
output_file="$(mktemp -d)/$file_name"
|
output_folder="$(mktemp -d)"
|
||||||
|
trap 'read -p "Press Enter to continue..."; rm -rf "$output_folder"' EXIT
|
||||||
|
output_file="$output_folder/$file_name"
|
||||||
|
|
||||||
# download the file
|
# download the file
|
||||||
log INFO "Download progress:"
|
log INFO "Download progress:"
|
||||||
@@ -1831,7 +1845,6 @@ function nexus() {
|
|||||||
[[ $mod_index -ne $new_mod_index ]] && mod_order -i "$new_mod_index" "$mod_index"
|
[[ $mod_index -ne $new_mod_index ]] && mod_order -i "$new_mod_index" "$mod_index"
|
||||||
|
|
||||||
log INFO "Mod ${GREEN}successfully${NC} updated: $mod_name."
|
log INFO "Mod ${GREEN}successfully${NC} updated: $mod_name."
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
disable_all_modpacks
|
disable_all_modpacks
|
||||||
|
|||||||
Reference in New Issue
Block a user