mirror of
https://github.com/tw93/Mole.git
synced 2026-03-22 22:30:08 +00:00
fix(clean): respect whitelist when cleaning Go caches (#530)
- Add whitelist checking to clean_dev_go() function - Check both GOCACHE and GOMODCACHE before cleaning - Show appropriate messages for protected caches - Fix whitelist pattern from ~/go/pkg/mod/cache/* to ~/go/pkg/mod/* - Split Go cache into separate build and module entries Fixes #521
This commit is contained in:
@@ -117,8 +117,50 @@ clean_dev_python() {
|
||||
# Go build/module caches.
|
||||
clean_dev_go() {
|
||||
if command -v go > /dev/null 2>&1; then
|
||||
clean_tool_cache "Go cache" bash -c 'go clean -modcache > /dev/null 2>&1 || true; go clean -cache > /dev/null 2>&1 || true'
|
||||
note_activity
|
||||
# Get Go cache paths
|
||||
local go_build_cache
|
||||
local go_mod_cache
|
||||
go_build_cache=$(go env GOCACHE 2> /dev/null || echo "$HOME/Library/Caches/go-build")
|
||||
go_mod_cache=$(go env GOMODCACHE 2> /dev/null || echo "$HOME/go/pkg/mod")
|
||||
|
||||
# Check if Go caches are whitelisted
|
||||
local build_protected=false
|
||||
local mod_protected=false
|
||||
|
||||
if is_path_whitelisted "$go_build_cache"; then
|
||||
build_protected=true
|
||||
fi
|
||||
|
||||
if is_path_whitelisted "$go_mod_cache"; then
|
||||
mod_protected=true
|
||||
fi
|
||||
|
||||
# Only clean if not protected by whitelist
|
||||
if [[ "$build_protected" == "true" && "$mod_protected" == "true" ]]; then
|
||||
if [[ "$DRY_RUN" == "true" ]]; then
|
||||
echo -e " ${YELLOW}${ICON_DRY_RUN}${NC} Go cache · would skip (whitelist)"
|
||||
else
|
||||
echo -e " ${BLUE}${ICON_SKIP}${NC} Go cache · protected by whitelist"
|
||||
fi
|
||||
elif [[ "$build_protected" == "true" ]]; then
|
||||
# Only clean module cache
|
||||
clean_tool_cache "Go module cache" bash -c 'go clean -modcache > /dev/null 2>&1 || true'
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
echo -e " ${BLUE}${ICON_SKIP}${NC} Go build cache · protected by whitelist"
|
||||
fi
|
||||
note_activity
|
||||
elif [[ "$mod_protected" == "true" ]]; then
|
||||
# Only clean build cache
|
||||
clean_tool_cache "Go build cache" bash -c 'go clean -cache > /dev/null 2>&1 || true'
|
||||
if [[ "$DRY_RUN" != "true" ]]; then
|
||||
echo -e " ${BLUE}${ICON_SKIP}${NC} Go module cache · protected by whitelist"
|
||||
fi
|
||||
note_activity
|
||||
else
|
||||
# Clean both caches
|
||||
clean_tool_cache "Go cache" bash -c 'go clean -modcache > /dev/null 2>&1 || true; go clean -cache > /dev/null 2>&1 || true'
|
||||
note_activity
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# Rust/cargo caches.
|
||||
|
||||
@@ -94,8 +94,8 @@ VS Code extension and update cache|$HOME/Library/Application Support/Code/Cached
|
||||
VS Code system cache (Cursor, VSCodium)|$HOME/Library/Caches/com.microsoft.VSCode/*|ide_cache
|
||||
Cursor editor cache|$HOME/Library/Caches/com.todesktop.230313mzl4w4u92/*|ide_cache
|
||||
Bazel build cache|$HOME/.cache/bazel/*|compiler_cache
|
||||
Go build cache and module cache|$HOME/Library/Caches/go-build/*|compiler_cache
|
||||
Go module cache|$HOME/go/pkg/mod/cache/*|compiler_cache
|
||||
Go build cache|$HOME/Library/Caches/go-build/*|compiler_cache
|
||||
Go module cache|$HOME/go/pkg/mod/*|compiler_cache
|
||||
Rust Cargo registry cache|$HOME/.cargo/registry/cache/*|compiler_cache
|
||||
Rust documentation cache|$HOME/.rustup/toolchains/*/share/doc/*|compiler_cache
|
||||
Rustup toolchain downloads|$HOME/.rustup/downloads/*|compiler_cache
|
||||
|
||||
Reference in New Issue
Block a user