Skip to content

Commit 58b607b

Browse files
FelixIsaacclaude
andcommitted
fix: skip symlinks/irregular files in WalkFiles, exclude node_modules/paste-cache/image-cache, match .git in nested paths
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 481720c commit 58b607b

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

internal/config/config.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ var DefaultExcludePatterns = []string{
7070
"shell-snapshots",
7171
"telemetry",
7272
"sessionStorage",
73+
"node_modules",
74+
"paste-cache",
75+
"image-cache",
7376
// Files
7477
"history.jsonl",
7578
"stats-cache.json",
@@ -153,6 +156,10 @@ func (c *Config) ShouldExclude(relPath string) bool {
153156
if relPathNorm == patternLower || strings.HasPrefix(relPathNorm, patternLower+"/") {
154157
return true
155158
}
159+
// Match pattern as a path component anywhere in the path (e.g. .git in nested dirs)
160+
if strings.Contains(relPathNorm, "/"+patternLower+"/") || strings.HasSuffix(relPathNorm, "/"+patternLower) {
161+
return true
162+
}
156163
// Exact filename match
157164
if strings.ToLower(filename) == patternLower {
158165
return true

internal/sync/sync.go

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,28 @@ func FileChecksum(path string) (string, error) {
3737
return hex.EncodeToString(h.Sum(nil)), nil
3838
}
3939

40-
// WalkFiles walks a directory and returns all file paths
40+
// WalkFiles walks a directory and returns all file paths, skipping symlinks and irregular files
4141
func WalkFiles(root string) ([]string, error) {
4242
var files []string
4343
err := filepath.Walk(root, func(path string, info os.FileInfo, err error) error {
4444
if err != nil {
4545
return err
4646
}
47+
// Skip symlinks: check both the symlink bit and irregular files
48+
// On Windows, os.Lstat may not set ModeSymlink for junction points,
49+
// so also skip files that are neither regular files nor directories
50+
linfo, lerr := os.Lstat(path)
51+
if lerr != nil {
52+
return nil
53+
}
54+
mode := linfo.Mode()
55+
if mode&os.ModeSymlink != 0 {
56+
return nil
57+
}
4758
if !info.IsDir() {
59+
if !mode.IsRegular() {
60+
return nil
61+
}
4862
files = append(files, path)
4963
}
5064
return nil

0 commit comments

Comments
 (0)