aboutsummaryrefslogtreecommitdiffstats
path: root/lib/crypto
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-08-23 21:36:23 +0200
committerRobin Jarry <robin@jarry.cc>2023-08-27 18:44:12 +0200
commita5bc7ccf0cae608ac1e72ab4c9ebe5596eb8c988 (patch)
treebe2e5f55fc21980489dca61947ea6b9819853ec3 /lib/crypto
parentfff16640ad7cd8c4b73187fbce10f2aa558701be (diff)
downloadaerc-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 'lib/crypto')
-rw-r--r--lib/crypto/pgp/pgp.go15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/crypto/pgp/pgp.go b/lib/crypto/pgp/pgp.go
index 8d7c135a..af406446 100644
--- a/lib/crypto/pgp/pgp.go
+++ b/lib/crypto/pgp/pgp.go
@@ -5,10 +5,10 @@ import (
"fmt"
"io"
"os"
- "path"
"strings"
"time"
+ "git.sr.ht/~rjarry/aerc/lib/xdg"
"git.sr.ht/~rjarry/aerc/log"
"git.sr.ht/~rjarry/aerc/models"
"github.com/ProtonMail/go-crypto/openpgp"
@@ -16,7 +16,6 @@ import (
"github.com/ProtonMail/go-crypto/openpgp/packet"
"github.com/emersion/go-message/mail"
"github.com/emersion/go-pgpmail"
- "github.com/kyoh86/xdg"
"github.com/pkg/errors"
)
@@ -29,7 +28,7 @@ var (
)
func (m *Mail) KeyringExists() bool {
- keypath := path.Join(xdg.DataHome(), "aerc", "keyring.asc")
+ keypath := xdg.DataPath("aerc", "keyring.asc")
keyfile, err := os.Open(keypath)
if err != nil {
return false
@@ -41,12 +40,12 @@ func (m *Mail) KeyringExists() bool {
func (m *Mail) Init() error {
log.Debugf("Initializing PGP keyring")
- err := os.MkdirAll(path.Join(xdg.DataHome(), "aerc"), 0o700)
+ err := os.MkdirAll(xdg.DataPath("aerc"), 0o700)
if err != nil {
return fmt.Errorf("failed to create data directory: %w", err)
}
- lockpath := path.Join(xdg.DataHome(), "aerc", "keyring.lock")
+ lockpath := xdg.DataPath("aerc", "keyring.lock")
lockfile, err := os.OpenFile(lockpath, os.O_CREATE|os.O_EXCL, 0o600)
if err != nil {
// TODO: Consider connecting to main process over IPC socket
@@ -56,7 +55,7 @@ func (m *Mail) Init() error {
lockfile.Close()
}
- keypath := path.Join(xdg.DataHome(), "aerc", "keyring.asc")
+ keypath := xdg.DataPath("aerc", "keyring.asc")
keyfile, err := os.Open(keypath)
if os.IsNotExist(err) {
return nil
@@ -76,7 +75,7 @@ func (m *Mail) Close() {
if !locked {
return
}
- lockpath := path.Join(xdg.DataHome(), "aerc", "keyring.lock")
+ lockpath := xdg.DataPath("aerc", "keyring.lock")
os.Remove(lockpath)
}
@@ -161,7 +160,7 @@ func (m *Mail) ImportKeys(r io.Reader) error {
}
Keyring = append(Keyring, keys...)
if locked {
- keypath := path.Join(xdg.DataHome(), "aerc", "keyring.asc")
+ keypath := xdg.DataPath("aerc", "keyring.asc")
keyfile, err := os.OpenFile(keypath, os.O_CREATE|os.O_APPEND, 0o600)
if err != nil {
return err