From 18aaddd8b1521ba408a9fd9210feded6f6544934 Mon Sep 17 00:00:00 2001 From: Levi Neely <141506390+lneely@users.noreply.github.com> Date: Tue, 19 May 2026 17:40:26 +0200 Subject: [PATCH] fix wstat panic on session rename OnRename callback already rewrites fid paths, so by the time wstat's fid update runs, f.path has changed. Use relPath for the new path computation instead of slicing f.path. --- server.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/server.go b/server.go index 2393d42..2221bbb 100644 --- a/server.go +++ b/server.go @@ -948,15 +948,17 @@ func (s *Server) wstat(cs *connState, fc *plan9.Fcall) *plan9.Fcall { if err := st.Rename(relPath, newDir.Name); err != nil { return errFcall(fc, err.Error()) } - // Update fid path. + // Update fid path (for non-session renames; session renames are + // handled by the OnRename callback which rewrites all affected fids). for _, r := range s.storeRoutes() { if strings.HasPrefix(f.path, r.prefix) { - // Replace the last path component with the new name. - parent := f.path[:len(f.path)-len(oldName)] - cs.mu.Lock() - f.path = parent + newDir.Name - f.qid.Path = qidPath(f.path) - cs.mu.Unlock() + newPath := r.prefix + relPath[:len(relPath)-len(oldName)] + newDir.Name + if newPath != f.path { + cs.mu.Lock() + f.path = newPath + f.qid.Path = qidPath(f.path) + cs.mu.Unlock() + } break } }