From 1b673b5ea7d06ef914e9d48ff7299f8b5f2119fd Mon Sep 17 00:00:00 2001 From: Jeffas Date: Sun, 21 Jul 2019 22:39:36 +0100 Subject: 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. --- lib/dirstore.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'lib') 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 +} -- cgit 1.4.1-2-gfad0