fix session.All/Get to use rootState.sessions map
All() and Get() were looking at root.Children() (mounted child trees) but sessions are stored in rootState.sessions. They were never mounted as children, so All() always returned empty — breaking D-Bus ListSessions and WatchExisting, causing the KDE GUI to see no restored sessions.
This commit is contained in:
parent
01fbf12fc5
commit
b9e1831167
|
|
@ -1,31 +1,25 @@
|
|||
// Package session builds the session/ file tree for the 9P namespace.
|
||||
// The tree IS the session collection — sessions are mounted children.
|
||||
// No manager, no store. Package functions for lifecycle.
|
||||
// The tree IS the session collection — rootState holds the sessions map.
|
||||
// Package functions for lifecycle, lookup, and enumeration.
|
||||
package session
|
||||
|
||||
import (
|
||||
"olliesrv/fs"
|
||||
)
|
||||
|
||||
// Get returns the Session mounted at id, or nil.
|
||||
// Get returns the Session for id, or nil.
|
||||
func Get(root *fs.Tree, id string) *Session {
|
||||
child := root.Child(id)
|
||||
if child == nil {
|
||||
return nil
|
||||
}
|
||||
if sess, ok := child.Data.(*Session); ok {
|
||||
return sess
|
||||
}
|
||||
return nil
|
||||
return Lookup(root, id)
|
||||
}
|
||||
|
||||
// All returns all mounted sessions.
|
||||
// All returns all active sessions.
|
||||
func All(root *fs.Tree) []*Session {
|
||||
var sessions []*Session
|
||||
for _, child := range root.Children() {
|
||||
if sess, ok := child.Data.(*Session); ok {
|
||||
rs := state(root)
|
||||
rs.mu.RLock()
|
||||
defer rs.mu.RUnlock()
|
||||
sessions := make([]*Session, 0, len(rs.sessions))
|
||||
for _, sess := range rs.sessions {
|
||||
sessions = append(sessions, sess)
|
||||
}
|
||||
}
|
||||
return sessions
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue