diff --git a/pkg/store/session.go b/pkg/store/session.go index 2339b34..5658be0 100644 --- a/pkg/store/session.go +++ b/pkg/store/session.go @@ -87,7 +87,8 @@ type SessionStoreConfig struct { MkdirAll func(string, os.FileMode) error // OnRename is called after a session is renamed in the map, // for protocol-level fixups (e.g. fid path rewriting). - OnRename func(oldID, newID string) + OnRename func(oldID, newID string) + SaveTranscript func([]byte) error } // SessionStore implements Store for session management. @@ -191,6 +192,21 @@ func (s *SessionStore) Session(id string) *Session { return s.sessions[id] } +// SessionFileStore returns a SessionFileStore for the given session ID. +func (s *SessionStore) SessionFileStore(id string) (*SessionFileStore, bool) { + sess := s.Session(id) + if sess == nil { + return nil, false + } + return NewSessionFileStore( + sess, + s.cfg.Log, + func() { s.KillSession(id) }, + func(newID string) error { return s.Rename(id, newID) }, + s.cfg.SaveTranscript, + ), true +} + // InterruptAll interrupts every active session. func (s *SessionStore) InterruptAll() { s.mu.RLock()