From cd2a5edb895994b0af7dd6413c88805cd430d5a5 Mon Sep 17 00:00:00 2001 From: s1eve-mcdichae1 <92833764+s1eve-mcdichae1@users.noreply.github.com> Date: Thu, 5 May 2022 20:43:45 -0700 Subject: [PATCH] ppsspp/lr-ppsspp: (bug) resolve conflict on removal Both stand-alone `ppsspp` and the libretro core `lr-ppsspp` share the `$HOME/.config/ppsspp` save file directory. `moveConfigDir` removes the symlink on removal; this will disconnects the existing saves from the remaining emulator. ppsspp: Use moveConfigDir only on install. On removal, do not use the helper function. Remove the symlink manually and only if no remaining PSP emulators. lr-ppsspp: Libretro core did not link this dir at all, and just used mkUserDir instead. Switch to use moveConfigDir and same fix as above, for libretro core also. --- scriptmodules/emulators/ppsspp.sh | 15 ++++++++++++--- scriptmodules/libretrocores/lr-ppsspp.sh | 9 ++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/scriptmodules/emulators/ppsspp.sh b/scriptmodules/emulators/ppsspp.sh index 53d856a184..682aeff1b9 100644 --- a/scriptmodules/emulators/ppsspp.sh +++ b/scriptmodules/emulators/ppsspp.sh @@ -172,10 +172,19 @@ function configure_ppsspp() { fi mkRomDir "psp" - moveConfigDir "$home/.config/ppsspp" "$md_conf_root/psp" - mkUserDir "$md_conf_root/psp/PSP" - ln -snf "$romdir/psp" "$md_conf_root/psp/PSP/GAME" + if [[ "$md_mode" == "install" ]]; then + moveConfigDir "$home/.config/ppsspp" "$md_conf_root/psp" + mkUserDir "$md_conf_root/psp/PSP" + ln -snf "$romdir/psp" "$md_conf_root/psp/PSP/GAME" + fi addEmulator 0 "$md_id" "psp" "pushd $md_inst; $md_inst/PPSSPPSDL ${extra_params[*]} %ROM%; popd" addSystem "psp" + + # if we are removing the last remaining psp emu - remove the symlink + if [[ "$md_mode" == "remove" ]]; then + if [[ -h "$home/.config/ppsspp" && ! -f "$md_conf_root/psp/emulators.cfg" ]]; then + rm -f "$home/.config/ppsspp" + fi + fi } diff --git a/scriptmodules/libretrocores/lr-ppsspp.sh b/scriptmodules/libretrocores/lr-ppsspp.sh index 95c1397310..0aefe8689f 100644 --- a/scriptmodules/libretrocores/lr-ppsspp.sh +++ b/scriptmodules/libretrocores/lr-ppsspp.sh @@ -48,9 +48,16 @@ function configure_lr-ppsspp() { # the core needs a save file directory, use the same folder as standalone 'ppsspp' iniConfig " = " "" "$configdir/psp/retroarch.cfg" iniSet "savefile_directory" "$home/.config/ppsspp" - mkUserDir "$home/.config/ppsspp" + moveConfigDir "$home/.config/ppsspp" "$md_conf_root/psp" fi addEmulator 1 "$md_id" "psp" "$md_inst/ppsspp_libretro.so" addSystem "psp" + + # if we are removing the last remaining psp emu - remove the symlink + if [[ "$md_mode" == "remove" ]]; then + if [[ -h "$home/.config/ppsspp" && ! -f "$md_conf_root/psp/emulators.cfg" ]]; then + rm -f "$home/.config/ppsspp" + fi + fi }