Use human readable file name for private Ox keys.

This commit is contained in:
Martin Dosch 2024-02-17 12:46:27 +01:00
parent 9c981474da
commit ae4a727cef
No known key found for this signature in database
GPG Key ID: 52A57CFCE13D657D
2 changed files with 12 additions and 1 deletions

View File

@ -1,6 +1,8 @@
# Changelog # Changelog
## UNRELEASED ## UNRELEASED
### Changed
- Use a human readable file name for private Ox keys.
## [v0.8.2] 2024-01-19 ## [v0.8.2] 2024-01-19
### Changed ### Changed

11
ox.go
View File

@ -344,7 +344,16 @@ func oxGetPrivKeyLoc(jid string) (string, error) {
return strError, fmt.Errorf("oxGetPrivKeyLoc: could not create folder for private keys: %w", err) 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 return dataFile, nil
} }