diff options
author | Robin Jarry <robin@jarry.cc> | 2023-08-23 21:36:23 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-08-27 18:44:12 +0200 |
commit | a5bc7ccf0cae608ac1e72ab4c9ebe5596eb8c988 (patch) | |
tree | be2e5f55fc21980489dca61947ea6b9819853ec3 /worker/imap | |
parent | fff16640ad7cd8c4b73187fbce10f2aa558701be (diff) | |
download | aerc-a5bc7ccf0cae608ac1e72ab4c9ebe5596eb8c988.tar.gz |
xdg: get rid of deprecated dependencies
github.com/mitchellh/go-homedir has not received any update since 2019.
The last release of github.com/kyoh86/xdg was in 2020 and it has been
marked as deprecated by its author.
Replace these with internal functions.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Reviewed-by: Moritz Poldrack <moritz@poldrack.dev>
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 |