fix: locking

This commit is contained in:
Jan Bader committed 2026-10-07 10:37:50 +02:00
1 parent c8a16d3f3e
commit 6041cc0a33
2 files changed
+27 -5

No files matched your search

+17 -5
View File
@@ -377,6 +377,8 @@ type lazyByIDNode struct {
client *DocspellClient
query string
limit int
mu sync.Mutex
shards map[string]*lazyByIDShardNode
}
type lazyByIDShardNode struct {
@@ -511,11 +513,21 @@ func (d *lazyByIDNode) Lookup(ctx context.Context, name string) (fs.Node, error)
if !isDocspellIDPrefix(name) {
return nil, fuse.ENOENT
}
return &lazyByIDShardNode{
query: combineItemQueries(d.query, "id:"+name+"*"),
client: d.client,
limit: d.limit,
}, nil
d.mu.Lock()
defer d.mu.Unlock()
if d.shards == nil {
d.shards = map[string]*lazyByIDShardNode{}
}
shard, ok := d.shards[name]
if !ok {
shard = &lazyByIDShardNode{
query: combineItemQueries(d.query, "id:"+name+"*"),
client: d.client,
limit: d.limit,
}
d.shards[name] = shard
}
return shard, nil
}
func (d *lazyByIDNode) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {