diff options
Diffstat (limited to 'worker/imap')
-rw-r--r-- | worker/imap/cache.go | 23 | ||||
-rw-r--r-- | worker/imap/configure.go | 7 |
2 files changed, 4 insertions, 26 deletions
diff --git a/worker/imap/cache.go b/worker/imap/cache.go index ec7cffd9..e33736cc 100644 --- a/worker/imap/cache.go +++ b/worker/imap/cache.go @@ -6,19 +6,17 @@ import ( "encoding/gob" "errors" "fmt" - "os" - "path" "strings" "time" "git.sr.ht/~rjarry/aerc/lib/parse" + "git.sr.ht/~rjarry/aerc/lib/xdg" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" "git.sr.ht/~rjarry/aerc/worker/types" "github.com/emersion/go-message" "github.com/emersion/go-message/mail" "github.com/emersion/go-message/textproto" - "github.com/mitchellh/go-homedir" "github.com/syndtr/goleveldb/leveldb" ) @@ -51,13 +49,7 @@ func (w *IMAPWorker) initCacheDb(acct string) { headerTag := strings.Join(w.config.headers, "") cacheTag = append(cacheTag, headerTag...) } - cd, err := cacheDir() - if err != nil { - w.cache = nil - w.worker.Errorf("unable to find cache directory: %v", err) - return - } - p := path.Join(cd, acct) + p := xdg.CachePath("aerc", acct) db, err := leveldb.OpenFile(p, nil) if err != nil { w.cache = nil @@ -171,17 +163,6 @@ func (w *IMAPWorker) headerKey(uid uint32) []byte { return []byte(key) } -func cacheDir() (string, error) { - dir, err := os.UserCacheDir() - if err != nil { - dir, err = homedir.Expand("~/.cache") - if err != nil { - return "", err - } - } - return path.Join(dir, "aerc"), nil -} - // cleanCache removes stale entries from the selected mailbox cachedb func (w *IMAPWorker) cleanCache(path string) { defer log.PanicHandler() diff --git a/worker/imap/configure.go b/worker/imap/configure.go index c325de23..49464689 100644 --- a/worker/imap/configure.go +++ b/worker/imap/configure.go @@ -9,10 +9,10 @@ import ( "strings" "time" + "git.sr.ht/~rjarry/aerc/lib/xdg" "git.sr.ht/~rjarry/aerc/worker/lib" "git.sr.ht/~rjarry/aerc/worker/middleware" "git.sr.ht/~rjarry/aerc/worker/types" - "github.com/mitchellh/go-homedir" "golang.org/x/oauth2" ) @@ -170,10 +170,7 @@ func (w *IMAPWorker) handleConfigure(msg *types.Configure) error { w.observer = newObserver(w.config, w.worker) if name, ok := msg.Config.Params["folder-map"]; ok { - file, err := homedir.Expand(name) - if err != nil { - return err - } + file := xdg.ExpandHome(name) f, err := os.Open(file) if err != nil { return err |