aerc/lib/dirstore.go
Jeffas 1b673b5ea7 Move msgstore map to dirstore
This map represents a mapping from directory names to their associated
messagestores anyway so they should be under dirstore. This simply moves
them there and adds some methods required to interact with them.
2019-07-26 14:15:27 -04:00

30 lines
647 B
Go

package lib
type DirStore struct {
dirs []string
msgStores map[string]*MessageStore
}
func NewDirStore() *DirStore {
msgStores := make(map[string]*MessageStore)
return &DirStore{msgStores: msgStores}
}
func (store *DirStore) Update(dirs []string) {
store.dirs = make([]string, len(dirs))
copy(store.dirs, dirs)
}
func (store *DirStore) List() []string {
return store.dirs
}
func (store *DirStore) MessageStore(dirname string) (*MessageStore, bool) {
msgStore, ok := store.msgStores[dirname]
return msgStore, ok
}
func (store *DirStore) SetMessageStore(name string, msgStore *MessageStore) {
store.msgStores[name] = msgStore
}