From 32797251287d6c8c1fc7f272633b897eed136e12 Mon Sep 17 00:00:00 2001 From: Ollie Agent Date: Sun, 2 Aug 2026 15:27:50 +0200 Subject: [PATCH] Inline three thin wrapper methods in server.go - openEntry (one-liner delegating to rootTree.Open): inlined into the two call sites in read() and write() - statPath (one-liner delegating to rootTree.Stat): inlined into three call sites (fileOwnerGroup, walk, makeStat) - InterruptAll (one-liner delegating to fs.InterruptAll): deleted, it was dead code with no callers anywhere Also cleaned up: removed unused File type alias and unused 'os' import. server.go: 825 -> 810 lines. Server method count drops by 3, but more importantly, zero forwarding boilerplate remains. --- cmd/olliesrv/server.go | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/cmd/olliesrv/server.go b/cmd/olliesrv/server.go index aa9ba8d..ee10c51 100644 --- a/cmd/olliesrv/server.go +++ b/cmd/olliesrv/server.go @@ -7,7 +7,6 @@ import ( "hash/fnv" "io" "net" - "os" "os/user" "strings" "sync" @@ -20,7 +19,6 @@ import ( ) type ( - File = fs.File FileTree = fs.FileTree syntheticFileInfo = fs.SyntheticFileInfo @@ -84,9 +82,6 @@ func New(cfg Config) *Server { } } -func (s *Server) openEntry(path string) (File, error) { return s.rootTree.Open(path[1:]) } -func (s *Server) statPath(path string) (os.FileInfo, error) { return s.rootTree.Stat(path[1:]) } - func (s *Server) AddGroup(group, user string) { s.mu.Lock() if s.groups[group] == nil { @@ -114,7 +109,7 @@ func (s *Server) InGroup(group, user string) bool { } func (s *Server) fileOwnerGroup(path string) (uid, gid string) { - info, err := s.statPath(path) + info, err := s.rootTree.Stat(path[1:]) if err == nil { if fi, ok := info.(*syntheticFileInfo); ok { if fi.UID_ != "" || fi.GID_ != "" { @@ -411,7 +406,7 @@ func (s *Server) walk(cs *connState, fc *plan9.Fcall) *plan9.Fcall { } else { next = pathJoin(cur, name) } - info, err := s.statPath(next) + info, err := s.rootTree.Stat(next[1:]) if err != nil { if len(wqids) == 0 { return errFcall(fc, name+": file not found") @@ -497,7 +492,7 @@ func (s *Server) read(cs *connState, fc *plan9.Fcall, ctx context.Context) *plan return &plan9.Fcall{Type: plan9.Rread, Tag: fc.Tag, Count: uint32(len(data)), Data: data} } - entry, err := s.openEntry(path) + entry, err := s.rootTree.Open(path[1:]) if err != nil { return errFcall(fc, err.Error()) } @@ -588,7 +583,7 @@ func (s *Server) write(cs *connState, fc *plan9.Fcall) *plan9.Fcall { return errFcall(fc, "bad fid") } - if entry, err := s.openEntry(f.path); err == nil && entry.RequestRespMode() { + if entry, err := s.rootTree.Open(f.path[1:]); err == nil && entry.RequestRespMode() { cs.mu.Unlock() if err := entry.Write(fc.Data); err != nil { return errFcall(fc, err.Error()) @@ -721,10 +716,6 @@ func (s *Server) Shutdown() { } } -func (s *Server) InterruptAll() { - fs.InterruptAll(s.rootTree) -} - func (s *Server) buildDirData(path string) []byte { var dirs []plan9.Dir @@ -788,7 +779,7 @@ func (s *Server) makeStat(path string) plan9.Dir { base = "." } - info, err := s.statPath(path) + info, err := s.rootTree.Stat(path[1:]) if err != nil { info = &syntheticFileInfo{Name_: base, Mode_: 0444} }