Skip to content

Commit

Permalink
Merge branch 'clear-gpu-cache-des-315'
Browse files Browse the repository at this point in the history
  • Loading branch information
raksooo committed Aug 30, 2023
2 parents ead6ae6 + ce047ef commit 9da8e2c
Showing 1 changed file with 42 additions and 20 deletions.
62 changes: 42 additions & 20 deletions dist-assets/linux/after-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit 9da8e2c

Please sign in to comment.