Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions lib/clean/caches.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ clean_project_caches() {
nextjs_tmp_file=$(create_temp_file)
local pycache_tmp_file
pycache_tmp_file=$(create_temp_file)
local find_timeout=10
local flutter_tmp_file
flutter_tmp_file=$(create_temp_file)
local find_timeout=30
# Parallel scans (Next.js and __pycache__).
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says this block runs parallel scans for “Next.js and pycache”, but it now also launches a Flutter scan. Update the comment to reflect all parallel scans so future changes don’t miss the extra process (and its timeout implications).

Suggested change
# Parallel scans (Next.js and __pycache__).
# Parallel scans (Next.js .next, Python __pycache__, Flutter .dart_tool).

Copilot uses AI. Check for mistakes.
(
command find "$HOME" -P -mount -type d -name ".next" -maxdepth 3 \
command find -P "$HOME" -mount -type d -name ".next" -maxdepth 3 \
-not -path "*/Library/*" \
-not -path "*/.Trash/*" \
-not -path "*/node_modules/*" \
Expand All @@ -168,25 +170,35 @@ clean_project_caches() {
) > "$nextjs_tmp_file" 2>&1 &
local next_pid=$!
(
command find "$HOME" -P -mount -type d -name "__pycache__" -maxdepth 3 \
command find -P "$HOME" -mount -type d -name "__pycache__" -maxdepth 3 \
-not -path "*/Library/*" \
-not -path "*/.Trash/*" \
-not -path "*/node_modules/*" \
-not -path "*/.*" \
2> /dev/null || true
) > "$pycache_tmp_file" 2>&1 &
local py_pid=$!
(
command find -P "$HOME" -mount -type d -name ".dart_tool" -maxdepth 5 \
-not -path "*/Library/*" \
-not -path "*/.Trash/*" \
-not -path "*/node_modules/*" \
-not -path "*/.*" \
-not -path "*/.fvm/*" \
Comment on lines 182 to 187
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Flutter scan searches for a dot-directory name (.dart_tool), which means you can’t use a blanket “/.” exclude, but as written it may still traverse large hidden directories under $HOME (e.g., ~/.cache) up to maxdepth 5. Consider switching to a prune-based find expression (or adding specific hidden-dir excludes) so the scan avoids heavy paths while still allowing .dart_tool matches.

Suggested change
command find -P "$HOME" -mount -type d -name ".dart_tool" -maxdepth 5 \
-not -path "*/Library/*" \
-not -path "*/.Trash/*" \
-not -path "*/node_modules/*" \
-not -path "*/.git/*" \
-not -path "*/.fvm/*" \
command find -P "$HOME" -mount -maxdepth 5 \
\( -path "$HOME/Library" -o \
-path "$HOME/.Trash" -o \
-path "$HOME/.cache" -o \
-path "*/node_modules" -o \
-path "*/.git" -o \
-path "*/.fvm" \) -prune -o \
-type d -name ".dart_tool" \

Copilot uses AI. Check for mistakes.
2> /dev/null || true
) > "$flutter_tmp_file" 2>&1 &
local flutter_pid=$!
local elapsed=0
local check_interval=0.2 # Check every 200ms instead of 1s for smoother experience
while [[ $(echo "$elapsed < $find_timeout" | awk '{print ($1 < $2)}') -eq 1 ]]; do
if ! kill -0 $next_pid 2> /dev/null && ! kill -0 $py_pid 2> /dev/null; then
if ! kill -0 $next_pid 2> /dev/null && ! kill -0 $py_pid 2> /dev/null && ! kill -0 $flutter_pid 2> /dev/null; then
break
fi
sleep $check_interval
elapsed=$(echo "$elapsed + $check_interval" | awk '{print $1 + $2}')
done
# Kill stuck scans after timeout.
for pid in $next_pid $py_pid; do
for pid in $next_pid $py_pid $flutter_pid; do
if kill -0 "$pid" 2> /dev/null; then
kill -TERM "$pid" 2> /dev/null || true
local grace_period=0
Expand Down Expand Up @@ -214,4 +226,13 @@ clean_project_caches() {
while IFS= read -r pycache; do
[[ -d "$pycache" ]] && safe_clean "$pycache"/* "Python bytecode cache" || true
done < "$pycache_tmp_file"
while IFS= read -r flutter_tool; do
if [[ -d "$flutter_tool" ]]; then
safe_clean "$flutter_tool" "Flutter build cache (.dart_tool)" || true
local build_dir="$(dirname "$flutter_tool")/build"
if [[ -d "$build_dir" ]]; then
safe_clean "$build_dir" "Flutter build cache (build/)" || true
fi
fi
done < "$flutter_tmp_file"
Comment on lines +229 to +237
Copy link

Copilot AI Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flutter cache cleaning (.dart_tool and sibling build/) is new behavior but there’s no test coverage asserting it’s detected/cleaned and that .fvm paths are ignored. Add a Bats test similar to the existing clean_project_caches tests that creates a sample Flutter project with .dart_tool + build, plus a .fvm/.dart_tool sentinel, and asserts only the project artifacts are targeted.

Copilot uses AI. Check for mistakes.
}
Loading