diff --git a/bin/analyze-go b/bin/analyze-go index a024b3a..49a740a 100755 Binary files a/bin/analyze-go and b/bin/analyze-go differ diff --git a/cmd/analyze/scanner.go b/cmd/analyze/scanner.go index f3a477b..ebd868f 100644 --- a/cmd/analyze/scanner.go +++ b/cmd/analyze/scanner.go @@ -75,6 +75,27 @@ func scanPathConcurrent(root string, filesScanned, dirsScanned, bytesScanned *in for _, child := range children { fullPath := filepath.Join(root, child.Name()) + // Skip symlinks to avoid following them into unexpected locations + // Use Type() instead of IsDir() to check without following symlinks + if child.Type()&fs.ModeSymlink != 0 { + // For symlinks, get their target info but mark them specially + info, err := child.Info() + if err != nil { + continue + } + size := getActualFileSize(fullPath, info) + atomic.AddInt64(&total, size) + + entryChan <- dirEntry{ + Name: child.Name() + " →", // Add arrow to indicate symlink + Path: fullPath, + Size: size, + IsDir: false, // Don't allow navigation into symlinks + LastAccess: getLastAccessTimeFromInfo(info), + } + continue + } + if child.IsDir() { // In root directory, skip system directories completely if isRootDir && skipSystemDirs[child.Name()] { @@ -383,6 +404,20 @@ func calculateDirSizeConcurrent(root string, largeFileChan chan<- fileEntry, fil for _, child := range children { fullPath := filepath.Join(root, child.Name()) + // Skip symlinks to avoid following them into unexpected locations + if child.Type()&fs.ModeSymlink != 0 { + // For symlinks, just count their size without following + info, err := child.Info() + if err != nil { + continue + } + size := getActualFileSize(fullPath, info) + total += size + atomic.AddInt64(filesScanned, 1) + atomic.AddInt64(bytesScanned, size) + continue + } + if child.IsDir() { // Check if this is a folded directory if shouldFoldDirWithPath(child.Name(), fullPath) { diff --git a/mole b/mole index cc00e64..6ef9a01 100755 --- a/mole +++ b/mole @@ -22,7 +22,7 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "$SCRIPT_DIR/lib/common.sh" # Version info -VERSION="1.9.17" +VERSION="1.9.18" MOLE_TAGLINE="can dig deep to clean your Mac." # Get latest version from remote repository