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