From eebb25753afb4881e334bb2d5429e96977e8dbfc Mon Sep 17 00:00:00 2001 From: Administrator <1280842908@qq.com> Date: Tue, 10 Mar 2026 10:59:32 +0800 Subject: [PATCH] fix(tools): implement fileSystem Open for ConcurrentFS and fix test cases --- pkg/tools/filesystem.go | 7 +++++++ pkg/tools/filesystem_test.go | 2 +- pkg/tools/team_test.go | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/tools/filesystem.go b/pkg/tools/filesystem.go index f7eb25297..9cfa2ae21 100644 --- a/pkg/tools/filesystem.go +++ b/pkg/tools/filesystem.go @@ -842,3 +842,10 @@ func (c *ConcurrentFS) ReadDir(path string) ([]os.DirEntry, error) { // Directories rarely suffer from single-file corruption, but we delegate anyway. return c.baseFS.ReadDir(path) } + +func (c *ConcurrentFS) Open(path string) (fs.File, error) { + lock := getPathLock(path) + lock.RLock() + defer lock.RUnlock() + return c.baseFS.Open(path) +} diff --git a/pkg/tools/filesystem_test.go b/pkg/tools/filesystem_test.go index 2a7b0483f..31597c8b5 100644 --- a/pkg/tools/filesystem_test.go +++ b/pkg/tools/filesystem_test.go @@ -533,7 +533,7 @@ func TestConcurrentFS_RaceCondition(t *testing.T) { func TestConcurrencyUpgradeable(t *testing.T) { // Verify that ReadFileTool implements the interface and upgrades correctly - readTool := NewReadFileTool("", false) + readTool := NewReadFileTool("", false, MaxReadFileSize) upgradable, ok := interface{}(readTool).(ConcurrencyUpgradeable) assert.True(t, ok, "ReadFileTool should implement ConcurrencyUpgradeable") diff --git a/pkg/tools/team_test.go b/pkg/tools/team_test.go index 9d76bdb2e..c49661249 100644 --- a/pkg/tools/team_test.go +++ b/pkg/tools/team_test.go @@ -11,7 +11,7 @@ func TestUpgradeRegistryForConcurrency(t *testing.T) { original := NewToolRegistry() // Register a mix of tools: some upgradeable, some not - readTool := NewReadFileTool("", false) + readTool := NewReadFileTool("", false, MaxReadFileSize) listTool := NewListDirTool("", false) // Not upgradeable writeTool := NewWriteFileTool("", false)