mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 15:00:07 +00:00
fix(uninstall): detect bundle-id-derived extension leftovers
Scan Application Scripts, Containers and FileProvider directories for entries that share the app bundle-id prefix (e.g. share extensions, file-provider extensions) so they are included in uninstall cleanup.
This commit is contained in:
@@ -1056,6 +1056,31 @@ find_app_files() {
|
||||
files_to_clean+=("$container")
|
||||
done < <(command find ~/Library/Group\ Containers -maxdepth 1 \( -name "*$bundle_id*" \) -print0 2> /dev/null)
|
||||
fi
|
||||
|
||||
# App extensions often use bundle-id-derived directories rather than the
|
||||
# main bundle id exactly, for example share extensions or file providers.
|
||||
local -a derived_bundle_roots=(
|
||||
"$HOME/Library/Application Scripts"
|
||||
"$HOME/Library/Containers"
|
||||
"$HOME/Library/Application Support/FileProvider"
|
||||
)
|
||||
local derived_root=""
|
||||
local derived_path=""
|
||||
local existing_path=""
|
||||
local already_added=false
|
||||
for derived_root in "${derived_bundle_roots[@]}"; do
|
||||
[[ -d "$derived_root" ]] || continue
|
||||
while IFS= read -r -d '' derived_path; do
|
||||
already_added=false
|
||||
for existing_path in "${files_to_clean[@]}"; do
|
||||
if [[ "$existing_path" == "$derived_path" ]]; then
|
||||
already_added=true
|
||||
break
|
||||
fi
|
||||
done
|
||||
[[ "$already_added" == "true" ]] || files_to_clean+=("$derived_path")
|
||||
done < <(command find "$derived_root" -maxdepth 1 -type d -name "*$bundle_id*" -print0 2> /dev/null)
|
||||
done
|
||||
fi
|
||||
|
||||
# Launch Agents by name (special handling)
|
||||
|
||||
@@ -109,6 +109,24 @@ setup() {
|
||||
[[ "$result" =~ .local/share/firefox ]]
|
||||
}
|
||||
|
||||
@test "find_app_files detects bundle-id-derived extension leftovers" {
|
||||
mkdir -p "$HOME/Library/Application Support/FileProvider/com.tencent.xinWeChat.WeChatFileProviderExtension"
|
||||
mkdir -p "$HOME/Library/Application Scripts/com.tencent.xinWeChat.WeChatMacShare"
|
||||
mkdir -p "$HOME/Library/Application Scripts/5A4RE8SF68.com.tencent.xinWeChat"
|
||||
mkdir -p "$HOME/Library/Containers/com.tencent.xinWeChat.WeChatFileProviderExtension"
|
||||
mkdir -p "$HOME/Library/Group Containers/5A4RE8SF68.com.tencent.xinWeChat"
|
||||
mkdir -p "$HOME/Library/Containers/com.tencent.otherapp.Helper"
|
||||
|
||||
result=$(find_app_files "com.tencent.xinWeChat" "WeChat")
|
||||
|
||||
[[ "$result" =~ "Library/Application Support/FileProvider/com.tencent.xinWeChat.WeChatFileProviderExtension" ]]
|
||||
[[ "$result" =~ "Library/Application Scripts/com.tencent.xinWeChat.WeChatMacShare" ]]
|
||||
[[ "$result" =~ "Library/Application Scripts/5A4RE8SF68.com.tencent.xinWeChat" ]]
|
||||
[[ "$result" =~ "Library/Containers/com.tencent.xinWeChat.WeChatFileProviderExtension" ]]
|
||||
[[ "$result" =~ "Library/Group Containers/5A4RE8SF68.com.tencent.xinWeChat" ]]
|
||||
[[ ! "$result" =~ "Library/Containers/com.tencent.otherapp.Helper" ]]
|
||||
}
|
||||
|
||||
@test "find_app_files does not match empty app name" {
|
||||
mkdir -p "$HOME/Library/Application Support/test"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user