From 082ba1c51195c217e1f8204a1e7bd25baff8072a Mon Sep 17 00:00:00 2001 From: Ollie Agent Date: Sun, 2 Aug 2026 15:31:33 +0200 Subject: [PATCH] fileOwnerGroup: convert from method to package-level function fileOwnerGroup only needed s.rootTree, not the full *Server. Making it a function taking (*fs.Tree, string) removes one more method from Server, makes the dependency explicit, and makes it unit-testable. --- cmd/olliesrv/server.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmd/olliesrv/server.go b/cmd/olliesrv/server.go index ee10c51..2d55bbc 100644 --- a/cmd/olliesrv/server.go +++ b/cmd/olliesrv/server.go @@ -108,8 +108,8 @@ func (s *Server) InGroup(group, user string) bool { return s.groups[group][user] } -func (s *Server) fileOwnerGroup(path string) (uid, gid string) { - info, err := s.rootTree.Stat(path[1:]) +func fileOwnerGroup(root *fs.Tree, path string) (uid, gid string) { + info, err := root.Stat(path[1:]) if err == nil { if fi, ok := info.(*syntheticFileInfo); ok { if fi.UID_ != "" || fi.GID_ != "" { @@ -124,7 +124,7 @@ func (s *Server) fileOwnerGroup(path string) (uid, gid string) { } func (s *Server) checkPerm(uname, path string, mode uint8) error { - uid, gid := s.fileOwnerGroup(path) + uid, gid := fileOwnerGroup(s.rootTree, path) dir := s.makeStat(path) perm := uint32(dir.Mode) & 0777 var bits uint32 @@ -790,7 +790,7 @@ func (s *Server) makeStat(path string) plan9.Dir { qid.Type = QTDir } - uid, gid := s.fileOwnerGroup(path) + uid, gid := fileOwnerGroup(s.rootTree, path) dir := plan9.Dir{ Qid: qid, Mode: plan9.Perm(info.Mode()),