From 797739ea7a25e806c5229133f38ec7a070c5a689 Mon Sep 17 00:00:00 2001 From: v4n <105587619+v4n00@users.noreply.github.com> Date: Fri, 7 Mar 2025 22:57:14 +0200 Subject: [PATCH] fix: uninstall correctly reindexes (fix #21) --- h2mm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/h2mm b/h2mm index 737c619..4eea0a9 100755 --- a/h2mm +++ b/h2mm @@ -836,8 +836,15 @@ function mod_uninstall() { [[ "$status" == "ENABLED" ]] && downgrade_mods "$files" # remove entry from database - sed -i "/^$mod_index,/d" "$DB_FILE" - log INFO "Mod $mod_name ${ORANGE}uninstalled${NC} successfully." + sed -i "/^$mod_index,/d" "$DB_FILE" + + # reindex the database + mods_to_reindex=($(awk -F, -v idx=$mod_index 'NR > 1 && $1 > idx {print $1}' "$DB_FILE")) + for idx in "${mods_to_reindex[@]}"; do + sed -i "s/^$idx,/$(($idx - 1)),/" "$DB_FILE" + done + + log INFO "Mod $mod_name ${ORANGE}uninstalled${NC} successfully." # disable any modpack disable_all_modpacks