From f21794d3d9c0cbe13c2394141f045d402f3ae621 Mon Sep 17 00:00:00 2001 From: tw93 Date: Mon, 16 Feb 2026 16:05:22 +0800 Subject: [PATCH] fix(clean): fix find -maxdepth position for BSD/macOS compatibility On macOS (BSD find), -maxdepth must be placed before -name to work correctly. When placed after, it was ignored causing find to scan the entire home directory indefinitely on large directories. Fixes #463 --- lib/clean/caches.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/clean/caches.sh b/lib/clean/caches.sh index 41cbb23..5caae16 100644 --- a/lib/clean/caches.sh +++ b/lib/clean/caches.sh @@ -162,8 +162,9 @@ clean_project_caches() { flutter_tmp_file=$(create_temp_file) local find_timeout=30 # Parallel scans (Next.js and __pycache__). + # Note: -maxdepth must come before -name for BSD find compatibility ( - command find -P "$HOME" -mount -type d -name ".next" -maxdepth 3 \ + command find -P "$HOME" -maxdepth 3 -mount -type d -name ".next" \ -not -path "*/Library/*" \ -not -path "*/.Trash/*" \ -not -path "*/node_modules/*" \ @@ -172,7 +173,7 @@ clean_project_caches() { ) > "$nextjs_tmp_file" 2>&1 & local next_pid=$! ( - command find -P "$HOME" -mount -type d -name "__pycache__" -maxdepth 3 \ + command find -P "$HOME" -maxdepth 3 -mount -type d -name "__pycache__" \ -not -path "*/Library/*" \ -not -path "*/.Trash/*" \ -not -path "*/node_modules/*" \ @@ -181,7 +182,7 @@ clean_project_caches() { ) > "$pycache_tmp_file" 2>&1 & local py_pid=$! ( - command find -P "$HOME" -mount -type d -name ".dart_tool" -maxdepth 5 \ + command find -P "$HOME" -maxdepth 5 -mount -type d -name ".dart_tool" \ -not -path "*/Library/*" \ -not -path "*/.Trash/*" \ -not -path "*/node_modules/*" \