mirror of
https://github.com/tw93/Mole.git
synced 2026-02-12 10:33:30 +00:00
fix: disable aggressive cleanup and optimize directory checks
This commit is contained in:
@@ -163,6 +163,14 @@ The analyzer (`mo analyze`) uses a different security model:
|
|||||||
|
|
||||||
**Code:** `lib/clean/apps.sh:orphan_detection()`
|
**Code:** `lib/clean/apps.sh:orphan_detection()`
|
||||||
|
|
||||||
|
#### New Language Ecosystem Support (v1.19.1+)
|
||||||
|
|
||||||
|
Added support for Elixir, Haskell, OCaml, and Editors (VS Code, Zed) with strict safety checks:
|
||||||
|
|
||||||
|
- **Existence Checks:** Cleanup logic only runs if the tool is installed (directory exists).
|
||||||
|
- **Safe Targets:** Only volatile caches are cleaned (e.g., `~/.hex/cache`).
|
||||||
|
- **Protected Paths:** Critical directories like `~/.mix/archives` (installed tools) and `~/.stack/programs` (installed compilers) are explicitly **excluded**.
|
||||||
|
|
||||||
#### Active Uninstallation Heuristics
|
#### Active Uninstallation Heuristics
|
||||||
|
|
||||||
For user-selected app removal:
|
For user-selected app removal:
|
||||||
|
|||||||
@@ -257,24 +257,34 @@ clean_sqlite_temp_files() {
|
|||||||
}
|
}
|
||||||
# Elixir/Erlang ecosystem.
|
# Elixir/Erlang ecosystem.
|
||||||
clean_dev_elixir() {
|
clean_dev_elixir() {
|
||||||
safe_clean ~/.mix/archives/* "Mix cache"
|
if [[ -d ~/.mix ]] || [[ -d ~/.hex ]]; then
|
||||||
safe_clean ~/.hex/cache/* "Hex cache"
|
# safe_clean ~/.mix/archives/* "Mix cache"
|
||||||
|
safe_clean ~/.hex/cache/* "Hex cache"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
# Haskell ecosystem.
|
# Haskell ecosystem.
|
||||||
clean_dev_haskell() {
|
clean_dev_haskell() {
|
||||||
safe_clean ~/.cabal/packages/* "Cabal install cache"
|
if [[ -d ~/.cabal ]] || [[ -d ~/.stack ]]; then
|
||||||
safe_clean ~/.stack/programs/* "Stack cache"
|
safe_clean ~/.cabal/packages/* "Cabal install cache"
|
||||||
|
# safe_clean ~/.stack/programs/* "Stack cache"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
# OCaml ecosystem.
|
# OCaml ecosystem.
|
||||||
clean_dev_ocaml() {
|
clean_dev_ocaml() {
|
||||||
safe_clean ~/.opam/download-cache/* "Opam cache"
|
if [[ -d ~/.opam ]]; then
|
||||||
|
safe_clean ~/.opam/download-cache/* "Opam cache"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
# Editor caches.
|
# Editor caches.
|
||||||
clean_dev_editors() {
|
clean_dev_editors() {
|
||||||
safe_clean ~/Library/Caches/com.microsoft.VSCode/Cache/* "VS Code cached data"
|
if [[ -d ~/Library/Caches/com.microsoft.VSCode ]] || [[ -d ~/Library/Application\ Support/Code ]]; then
|
||||||
safe_clean ~/Library/Application\ Support/Code/CachedData/* "VS Code cached data"
|
safe_clean ~/Library/Caches/com.microsoft.VSCode/Cache/* "VS Code cached data"
|
||||||
safe_clean ~/Library/Application\ Support/Code/User/workspaceStorage/* "VS Code workspace storage"
|
safe_clean ~/Library/Application\ Support/Code/CachedData/* "VS Code cached data"
|
||||||
safe_clean ~/Library/Caches/Zed/* "Zed cache"
|
# safe_clean ~/Library/Application\ Support/Code/User/workspaceStorage/* "VS Code workspace storage"
|
||||||
|
fi
|
||||||
|
if [[ -d ~/Library/Caches/Zed ]]; then
|
||||||
|
safe_clean ~/Library/Caches/Zed/* "Zed cache"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
# Main developer tools cleanup sequence.
|
# Main developer tools cleanup sequence.
|
||||||
clean_developer_tools() {
|
clean_developer_tools() {
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ teardown_file() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "clean_dev_elixir cleans mix and hex caches" {
|
@test "clean_dev_elixir cleans mix and hex caches" {
|
||||||
|
mkdir -p "$HOME/.mix" "$HOME/.hex"
|
||||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||||
@@ -30,11 +31,12 @@ clean_dev_elixir
|
|||||||
EOF
|
EOF
|
||||||
|
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ "$output" == *"Mix cache"* ]]
|
|
||||||
[[ "$output" == *"Hex cache"* ]]
|
[[ "$output" == *"Hex cache"* ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "clean_dev_haskell cleans cabal install and stack caches" {
|
@test "clean_dev_haskell cleans cabal install and stack caches" {
|
||||||
|
mkdir -p "$HOME/.cabal" "$HOME/.stack"
|
||||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||||
@@ -45,10 +47,11 @@ EOF
|
|||||||
|
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ "$output" == *"Cabal install cache"* ]]
|
[[ "$output" == *"Cabal install cache"* ]]
|
||||||
[[ "$output" == *"Stack cache"* ]]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "clean_dev_ocaml cleans opam cache" {
|
@test "clean_dev_ocaml cleans opam cache" {
|
||||||
|
mkdir -p "$HOME/.opam"
|
||||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||||
@@ -62,6 +65,7 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
@test "clean_dev_editors cleans VS Code and Zed caches" {
|
@test "clean_dev_editors cleans VS Code and Zed caches" {
|
||||||
|
mkdir -p "$HOME/Library/Caches/com.microsoft.VSCode" "$HOME/Library/Application Support/Code" "$HOME/Library/Caches/Zed"
|
||||||
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
run env HOME="$HOME" PROJECT_ROOT="$PROJECT_ROOT" bash --noprofile --norc <<'EOF'
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
source "$PROJECT_ROOT/lib/core/common.sh"
|
source "$PROJECT_ROOT/lib/core/common.sh"
|
||||||
@@ -72,6 +76,6 @@ EOF
|
|||||||
|
|
||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ "$output" == *"VS Code cached data"* ]]
|
[[ "$output" == *"VS Code cached data"* ]]
|
||||||
[[ "$output" == *"VS Code workspace storage"* ]]
|
|
||||||
[[ "$output" == *"Zed cache"* ]]
|
[[ "$output" == *"Zed cache"* ]]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user