Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stbridge/saf.go
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ func (sn *safNode) getChildren(opts *safOpts, allowFiles bool) (map[string]*safN

sn.updateChildrenLocked(opts, children, expiry.Unix())

return children, nil
return maps.Clone(children), nil
}

// Get the child node referenced by the specified relative path. ".." components
Expand Down
7 changes: 7 additions & 0 deletions stbridge/saf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"maps"
"os"
"path/filepath"
"reflect"
"slices"
"strconv"
"syscall"
Expand Down Expand Up @@ -317,6 +318,9 @@ func TestGetChildren(t *testing.T) {
if calls != 1 {
t.Errorf("queryChildDocumentsJson was not called when expired")
}
if reflect.ValueOf(children).Pointer() == reflect.ValueOf(node.children).Pointer() {
t.Errorf("children was not a copy: %p (%+v)", children, children)
}
if len(children) != 2 {
t.Errorf("invalid number of children")
}
Expand All @@ -341,6 +345,9 @@ func TestGetChildren(t *testing.T) {
if calls != 1 {
t.Errorf("queryChildDocumentsJson was called when not expired")
}
if reflect.ValueOf(children).Pointer() == reflect.ValueOf(node.children).Pointer() {
t.Errorf("children was not a copy: %p (%+v)", children, children)
}
if !maps.Equal(children, oldChildren) {
t.Errorf("children changed: %+v != %+v", children, oldChildren)
}
Expand Down
Loading