diff options
author | Tim Culverhouse <tim@timculverhouse.com> | 2023-04-16 09:53:42 -0500 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-04-22 22:40:12 +0200 |
commit | 2438d3b74ff9faf598e67f4b6da9324aa98b8b86 (patch) | |
tree | 6eadb0bbe3b4ae4cfc4a9ae2ae6fb2773cb4da23 /lib/dirstore.go | |
parent | 2ed7a741ff9eca1dd3fe9e94cdcfe4f365b74ff2 (diff) | |
download | aerc-2438d3b74ff9faf598e67f4b6da9324aa98b8b86.tar.gz |
dirstore: store directory model in dirstore
Use the dirstore to store models.Directory data structures. This will be
used in subsequent commits for accessing directory data.
Signed-off-by: Tim Culverhouse <tim@timculverhouse.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/dirstore.go')
-rw-r--r-- | lib/dirstore.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/dirstore.go b/lib/dirstore.go index cc06d579..76833622 100644 --- a/lib/dirstore.go +++ b/lib/dirstore.go @@ -1,12 +1,17 @@ package lib +import "git.sr.ht/~rjarry/aerc/models" + type DirStore struct { + dirs map[string]*models.Directory msgStores map[string]*MessageStore } func NewDirStore() *DirStore { - msgStores := make(map[string]*MessageStore) - return &DirStore{msgStores: msgStores} + return &DirStore{ + dirs: make(map[string]*models.Directory), + msgStores: make(map[string]*MessageStore), + } } func (store *DirStore) List() []string { @@ -22,10 +27,12 @@ func (store *DirStore) MessageStore(dirname string) (*MessageStore, bool) { return msgStore, ok } -func (store *DirStore) SetMessageStore(name string, msgStore *MessageStore) { - store.msgStores[name] = msgStore +func (store *DirStore) SetMessageStore(dir *models.Directory, msgStore *MessageStore) { + store.dirs[dir.Name] = dir + store.msgStores[dir.Name] = msgStore } func (store *DirStore) Remove(name string) { + delete(store.dirs, name) delete(store.msgStores, name) } |