summary refs log tree commit diff stats
path: root/lib
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-07-21 22:39:36 +0100
committerDrew DeVault <sir@cmpwn.com>2019-07-26 14:15:27 -0400
commit1b673b5ea7d06ef914e9d48ff7299f8b5f2119fd (patch)
tree7b6598470500ec2fd923fb6f0939409c25963d79 /lib
parentdc4c36adbfbffd34319ddc007bad437ef802ee72 (diff)
downloadaerc-1b673b5ea7d06ef914e9d48ff7299f8b5f2119fd.tar.gz
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.
Diffstat (limited to 'lib')
-rw-r--r--lib/dirstore.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/dirstore.go b/lib/dirstore.go
index 862e97a..bb58a9d 100644
--- a/lib/dirstore.go
+++ b/lib/dirstore.go
@@ -1,11 +1,13 @@
 package lib
 
 type DirStore struct {
-	dirs []string
+	dirs      []string
+	msgStores map[string]*MessageStore
 }
 
 func NewDirStore() *DirStore {
-	return &DirStore{}
+	msgStores := make(map[string]*MessageStore)
+	return &DirStore{msgStores: msgStores}
 }
 
 func (store *DirStore) Update(dirs []string) {
@@ -16,3 +18,12 @@ func (store *DirStore) Update(dirs []string) {
 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
+}