Skip to content

Commit c8a9ae8

Browse files
committed
Remove unused methods
Signed-off-by: Guillaume Tardif <guillaume.tardif@gmail.com>
1 parent 2699241 commit c8a9ae8

4 files changed

Lines changed: 5 additions & 22 deletions

File tree

pkg/fsx/collect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func CollectFiles(ctx context.Context, paths []string, shouldIgnore func(path st
5858

5959
if info.IsDir() {
6060
// Use DirectoryTree to collect files from directory
61-
tree, err := DirectoryTreeWithContext(ctx, normalized, func(string) error { return nil }, shouldIgnore, 0)
61+
tree, err := DirectoryTree(ctx, normalized, func(string) error { return nil }, shouldIgnore, 0)
6262
if err != nil {
6363
return nil, fmt.Errorf("failed to read directory %s: %w", normalized, err)
6464
}

pkg/fsx/collect_cancellation_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func TestDirectoryTree_ContextCancellation(t *testing.T) {
7070
// Cancel context immediately
7171
cancel()
7272

73-
_, err := DirectoryTreeWithContext(ctx, tmpDir, func(string) error { return nil }, nil, 0)
73+
_, err := DirectoryTree(ctx, tmpDir, func(string) error { return nil }, nil, 0)
7474
assert.ErrorIs(t, err, context.Canceled)
7575
})
7676

@@ -81,7 +81,7 @@ func TestDirectoryTree_ContextCancellation(t *testing.T) {
8181
// Give time for timeout to trigger
8282
time.Sleep(10 * time.Millisecond)
8383

84-
_, err := DirectoryTreeWithContext(ctx, tmpDir, func(string) error { return nil }, nil, 0)
84+
_, err := DirectoryTree(ctx, tmpDir, func(string) error { return nil }, nil, 0)
8585
assert.ErrorIs(t, err, context.DeadlineExceeded)
8686
})
8787
}

pkg/fsx/fs.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ type TreeNode struct {
1515
Children []*TreeNode `json:"children,omitempty"`
1616
}
1717

18-
func DirectoryTree(path string, isPathAllowed func(string) error, shouldIgnore func(string) bool, maxItems int) (*TreeNode, error) {
19-
itemCount := 0
20-
return directoryTree(context.Background(), path, isPathAllowed, shouldIgnore, maxItems, &itemCount)
21-
}
22-
23-
// DirectoryTreeWithContext is a context-aware version of DirectoryTree.
24-
func DirectoryTreeWithContext(ctx context.Context, path string, isPathAllowed func(string) error, shouldIgnore func(string) bool, maxItems int) (*TreeNode, error) {
18+
func DirectoryTree(ctx context.Context, path string, isPathAllowed func(string) error, shouldIgnore func(string) bool, maxItems int) (*TreeNode, error) {
2519
itemCount := 0
2620
return directoryTree(ctx, path, isPathAllowed, shouldIgnore, maxItems, &itemCount)
2721
}
@@ -87,17 +81,6 @@ func directoryTree(ctx context.Context, path string, isPathAllowed func(string)
8781
return node, nil
8882
}
8983

90-
func ListDirectory(path string, shouldIgnore func(string) bool) ([]string, error) {
91-
tree, err := DirectoryTree(path, func(string) error { return nil }, shouldIgnore, 0)
92-
if err != nil {
93-
return nil, err
94-
}
95-
96-
var files []string
97-
CollectFilesFromTree(tree, "", &files)
98-
return files, nil
99-
}
100-
10184
// CollectFilesFromTree recursively collects file paths from a DirectoryTree.
10285
// Pass basePath="" for relative paths, or a parent directory for absolute paths.
10386
func CollectFilesFromTree(node *TreeNode, basePath string, files *[]string) {

pkg/tools/builtin/filesystem.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func (t *FilesystemTool) handleDirectoryTree(ctx context.Context, args Directory
391391
return nil
392392
}
393393

394-
tree, err := fsx.DirectoryTreeWithContext(ctx, resolvedPath, isPathAllowed, t.shouldIgnorePath, maxFiles)
394+
tree, err := fsx.DirectoryTree(ctx, resolvedPath, isPathAllowed, t.shouldIgnorePath, maxFiles)
395395
if err != nil {
396396
return tools.ResultError(fmt.Sprintf("Error building directory tree: %s", err)), nil
397397
}

0 commit comments

Comments
 (0)