resume active sessions
This commit is contained in:
1 parent
9e94c05fb6
commit
917a361370
19 files changed
+871
-42
No files matched your search
@@ -13,9 +13,10 @@ import (
|
||||
)
|
||||
|
||||
type Store struct {
|
||||
path string
|
||||
mu sync.Mutex
|
||||
data struct {
|
||||
path string
|
||||
mu sync.Mutex
|
||||
turns map[string]map[string]*model.Turn // channel → thread → turn, one in-flight file per channel
|
||||
data struct {
|
||||
Owners map[string]*model.Owner `json:"owners"`
|
||||
Sessions map[string]*model.Session `json:"sessions"`
|
||||
Permissions *model.PermissionsConfig `json:"permissions,omitempty"`
|
||||
@@ -24,14 +25,17 @@ type Store struct {
|
||||
}
|
||||
|
||||
func Open(path string) (*Store, error) {
|
||||
s := &Store{path: path}
|
||||
s := &Store{path: path, turns: map[string]map[string]*model.Turn{}}
|
||||
s.data.Owners = map[string]*model.Owner{}
|
||||
s.data.Sessions = map[string]*model.Session{}
|
||||
s.data.Listen = map[string]model.ListenMode{}
|
||||
|
||||
b, err := os.ReadFile(path)
|
||||
if errors.Is(err, os.ErrNotExist) {
|
||||
return s, os.MkdirAll(filepath.Dir(path), 0o700)
|
||||
if err := os.MkdirAll(filepath.Dir(path), 0o700); err != nil {
|
||||
return s, err
|
||||
}
|
||||
return s, s.loadTurns()
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -48,7 +52,7 @@ func Open(path string) (*Store, error) {
|
||||
if s.data.Listen == nil {
|
||||
s.data.Listen = map[string]model.ListenMode{}
|
||||
}
|
||||
return s, nil
|
||||
return s, s.loadTurns()
|
||||
}
|
||||
|
||||
func (s *Store) save() error {
|
||||
|
||||
Reference in new issue
Block a user