From ae4a727cef2f0c74c87b9ecd6036fd20f8b68198 Mon Sep 17 00:00:00 2001 From: Martin Dosch Date: Sat, 17 Feb 2024 12:46:27 +0100 Subject: [PATCH] Use human readable file name for private Ox keys. --- CHANGELOG.md | 2 ++ ox.go | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c20545b..941938f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Changelog ## UNRELEASED +### Changed +- Use a human readable file name for private Ox keys. ## [v0.8.2] 2024-01-19 ### Changed diff --git a/ox.go b/ox.go index 19a5bf4..c0f3c6e 100644 --- a/ox.go +++ b/ox.go @@ -344,7 +344,16 @@ func oxGetPrivKeyLoc(jid string) (string, error) { return strError, fmt.Errorf("oxGetPrivKeyLoc: could not create folder for private keys: %w", err) } } - dataFile := dataDir + base64.StdEncoding.EncodeToString([]byte(jid)) + // TODO: Remove handling of oldDataFile in a later version when it's very likely that there are no + // more versions in use using the oldDataFile. + oldDataFile := dataDir + base64.StdEncoding.EncodeToString([]byte(jid)) + dataFile := dataDir + strings.Replace(jid, "@", "_at_", -1) + if _, err := os.Stat(oldDataFile); err == nil { + err := os.Rename(oldDataFile, dataFile) + if err != nil { + return dataFile, err + } + } return dataFile, nil }