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.
This commit is contained in:
Levi Neely 2026-05-19 17:40:26 +02:00
parent 4faa341558
commit 18aaddd8b1
1 changed files with 9 additions and 7 deletions

View File

@ -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
}
}