From ce047efa923f98791c9b36345c199d2f6bc9dc16 Mon Sep 17 00:00:00 2001 From: Oskar Nyberg Date: Tue, 29 Aug 2023 18:30:50 +0200 Subject: [PATCH] Clear GPU cache on upgrade on Linux --- dist-assets/linux/after-remove.sh | 62 +++++++++++++++++++++---------- 1 file changed, 42 insertions(+), 20 deletions(-) diff --git a/dist-assets/linux/after-remove.sh b/dist-assets/linux/after-remove.sh index 8dfe875a46da..2b3a93e5f26b 100644 --- a/dist-assets/linux/after-remove.sh +++ b/dist-assets/linux/after-remove.sh @@ -8,32 +8,50 @@ function remove_logs_and_cache { echo "Failed to remove mullvad-vpn cache" } +function get_home_dirs { + if [[ -f "/etc/passwd" ]] && command -v cut > /dev/null; then + cut -d: -f6 /etc/passwd + fi +} + +function clear_gpu_cache { + local home_dirs + home_dirs=$(get_home_dirs) + + for home_dir in $home_dirs; do + local gpu_cache_dir="$home_dir/.config/Mullvad VPN/GPUCache" + if [[ -d "$gpu_cache_dir" ]]; then + echo "Clearing GPU cache in $gpu_cache_dir" + rm -r --interactive=never "$gpu_cache_dir" || \ + echo "Failed to clear GPU cache" + fi + done +} + function remove_config { rm -r --interactive=never /etc/mullvad-vpn || \ echo "Failed to remove mullvad-vpn config" # Remove app settings and auto-launcher for all users. This doesn't respect XDG_CONFIG_HOME due # to the complexity required. - if [[ -f "/etc/passwd" ]] && command -v cut > /dev/null; then - local home_dirs - home_dirs=$(cut -d: -f6 /etc/passwd) - for home_dir in $home_dirs; do - local mullvad_dir="$home_dir/.config/Mullvad VPN" - if [[ -d "$mullvad_dir" ]]; then - echo "Removing mullvad-vpn app settings from $mullvad_dir" - rm -r --interactive=never "$mullvad_dir" || \ - echo "Failed to remove mullvad-vpn app settings" - fi - - local autostart_path="$home_dir/.config/autostart/mullvad-vpn.desktop" - # mullvad-vpn.desktop can be both a file or a symlink. - if [[ -f "$autostart_path" || -L "$autostart_path" ]]; then - echo "Removing mullvad-vpn app autostart file $autostart_path" - rm --interactive=never "$autostart_path" || \ - echo "Failed to remove mullvad-vpn autostart file" - fi - done - fi + local home_dirs + home_dirs=$(get_home_dirs) + for home_dir in $home_dirs; do + local mullvad_dir="$home_dir/.config/Mullvad VPN" + if [[ -d "$mullvad_dir" ]]; then + echo "Removing mullvad-vpn app settings from $mullvad_dir" + rm -r --interactive=never "$mullvad_dir" || \ + echo "Failed to remove mullvad-vpn app settings" + fi + + local autostart_path="$home_dir/.config/autostart/mullvad-vpn.desktop" + # mullvad-vpn.desktop can be both a file or a symlink. + if [[ -f "$autostart_path" || -L "$autostart_path" ]]; then + echo "Removing mullvad-vpn app autostart file $autostart_path" + rm --interactive=never "$autostart_path" || \ + echo "Failed to remove mullvad-vpn autostart file" + fi + done } # checking what kind of an action is taking place @@ -52,3 +70,7 @@ case $@ in remove_config ;; esac + +# Different electron versions can have incompatible GPU caches. Clearing it on upgrades makes sure +# the same cache is not used across versions. +clear_gpu_cache