Skip to content

Commit 528b1f2

Browse files
clkaoclaude
andcommitted
fix: follow symlinks when discovering project directories
os.ReadDir returns DirEntry where IsDir() is false for symlinks to directories. This caused DiscoverClaudeProjects and the Gemini discovery functions to silently skip symlinked project directories, making CLAUDE_PROJECTS_DIR unusable with symlinked repos. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d8da907 commit 528b1f2

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

internal/sync/discovery.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ var uuidRe = regexp.MustCompile(
2020
`[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$`,
2121
)
2222

23+
// isDirOrSymlink reports whether the entry is a directory or a
24+
// symlink (which may point to a directory).
25+
func isDirOrSymlink(entry os.DirEntry) bool {
26+
return entry.IsDir() || entry.Type()&os.ModeSymlink != 0
27+
}
28+
2329
// DiscoveredFile holds a discovered session JSONL file.
2430
type DiscoveredFile struct {
2531
Path string
@@ -37,7 +43,7 @@ func DiscoverClaudeProjects(projectsDir string) []DiscoveredFile {
3743

3844
var files []DiscoveredFile
3945
for _, entry := range entries {
40-
if !entry.IsDir() {
46+
if !isDirOrSymlink(entry) {
4147
continue
4248
}
4349

@@ -271,7 +277,7 @@ func DiscoverGeminiSessions(
271277

272278
var files []DiscoveredFile
273279
for _, hd := range hashDirs {
274-
if !hd.IsDir() {
280+
if !isDirOrSymlink(hd) {
275281
continue
276282
}
277283
hash := hd.Name()
@@ -326,7 +332,7 @@ func FindGeminiSourceFile(
326332
}
327333

328334
for _, hd := range hashDirs {
329-
if !hd.IsDir() {
335+
if !isDirOrSymlink(hd) {
330336
continue
331337
}
332338
chatsDir := filepath.Join(tmpDir, hd.Name(), "chats")

0 commit comments

Comments
 (0)