session/fs: handle empty sessions during persistence
persistSession: check sess.Core.Agent() != nil before saving. silently skip sessions with no agent instead of logging 'no active session' error on shutdown. SaveSession: return nil (no-op) when there are no agents, rather than returning an error that gets logged.
This commit is contained in:
parent
cb13f6523c
commit
b1cbb9ca7c
|
|
@ -134,7 +134,8 @@ func persistSession(rs *rootState, id string) {
|
|||
if !ok {
|
||||
return
|
||||
}
|
||||
if sess.Core == nil {
|
||||
if sess.Core == nil || sess.Core.Agent() == nil {
|
||||
// Empty session — no agent to persist. Silently skip.
|
||||
return
|
||||
}
|
||||
dir := activeSessionsDir(rs)
|
||||
|
|
|
|||
|
|
@ -346,9 +346,10 @@ func (a *Session) flushSave() {
|
|||
}
|
||||
|
||||
// SaveSession writes the current session state to the given path.
|
||||
// Returns nil if there is no agent (empty session).
|
||||
func (a *Session) SaveSession(path string) error {
|
||||
if ag := a.Agent(); ag != nil {
|
||||
return ag.SaveFull(path, a.id, a.CWD(), a.remote)
|
||||
}
|
||||
return fmt.Errorf("no agent in session")
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue