Don't allow lgm to try and remove files under lgm's own directory, for games that simply have a launcher script.

This commit is contained in:
Michael Taboada 2023-11-30 18:44:21 -08:00
parent e7e14886ad
commit b2347f3cff

View File

@ -334,9 +334,20 @@ game_removal() {
exit 0
fi
fi
dialog --backtitle "Linux Game Manager" \
--yesno "mThis will remove the directory \"${game%/*}\" and all of its contents. Do you want to continue?." -1 -1 --stdout || exit 0
{ rm -rfv "${game%/*}";
local launcherPath="$(readlink -f "$0")"
launcherPath="${launcherPath%/*}"
local noRemove="no"
if [[ "${game%/*}" =~ ^$launcherPath ]] ; then
# The launcher is actually a script under lgm, do not remove.
noRemove="yes"
dialog --backtitle "Linux Game Manager" \
--yesno "This will remove the game from your game list, but will not remove any files. Do you want to continue?." -1 -1 --stdout || exit 0
else
dialog --backtitle "Linux Game Manager" \
--yesno "mThis will remove the directory \"${game%/*}\" and all of its contents. Do you want to continue?." -1 -1 --stdout || exit 0
fi
export noRemove
{ [ "$noRemove" == "no" ] && rm -rfv "${game%/*}";
sed -i "/${game//\//\\/}/d" "$configFile"; } | dialog --backtitle "Linux Game Manager" --progressbox "Removing game..." -1 -1
exit 0
}