fix(tools): implement fileSystem Open for ConcurrentFS and fix test cases
This commit is contained in:
parent
e49c801054
commit
eebb25753a
3 changed files with 9 additions and 2 deletions
|
|
@ -842,3 +842,10 @@ func (c *ConcurrentFS) ReadDir(path string) ([]os.DirEntry, error) {
|
||||||
// Directories rarely suffer from single-file corruption, but we delegate anyway.
|
// Directories rarely suffer from single-file corruption, but we delegate anyway.
|
||||||
return c.baseFS.ReadDir(path)
|
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)
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -533,7 +533,7 @@ func TestConcurrentFS_RaceCondition(t *testing.T) {
|
||||||
|
|
||||||
func TestConcurrencyUpgradeable(t *testing.T) {
|
func TestConcurrencyUpgradeable(t *testing.T) {
|
||||||
// Verify that ReadFileTool implements the interface and upgrades correctly
|
// Verify that ReadFileTool implements the interface and upgrades correctly
|
||||||
readTool := NewReadFileTool("", false)
|
readTool := NewReadFileTool("", false, MaxReadFileSize)
|
||||||
upgradable, ok := interface{}(readTool).(ConcurrencyUpgradeable)
|
upgradable, ok := interface{}(readTool).(ConcurrencyUpgradeable)
|
||||||
assert.True(t, ok, "ReadFileTool should implement ConcurrencyUpgradeable")
|
assert.True(t, ok, "ReadFileTool should implement ConcurrencyUpgradeable")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ func TestUpgradeRegistryForConcurrency(t *testing.T) {
|
||||||
original := NewToolRegistry()
|
original := NewToolRegistry()
|
||||||
|
|
||||||
// Register a mix of tools: some upgradeable, some not
|
// Register a mix of tools: some upgradeable, some not
|
||||||
readTool := NewReadFileTool("", false)
|
readTool := NewReadFileTool("", false, MaxReadFileSize)
|
||||||
listTool := NewListDirTool("", false) // Not upgradeable
|
listTool := NewListDirTool("", false) // Not upgradeable
|
||||||
writeTool := NewWriteFileTool("", false)
|
writeTool := NewWriteFileTool("", false)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue