1
0
mirror of https://github.com/osmarks/mycorrhiza.git synced 2024-12-12 05:20:26 +00:00

Merge pull request #38 from GuAlSe/0.14

Fix token storage path
This commit is contained in:
Timur Ismagilov 2021-03-06 01:45:35 +05:00 committed by GitHub
commit db75078452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -4,6 +4,7 @@ import (
"encoding/json"
"io/ioutil"
"log"
"strings"
"os"
"github.com/adrg/xdg"
@ -62,10 +63,10 @@ func readTokensToUsers() {
func tokenStoragePath() string {
dir, err := xdg.DataFile("mycorrhiza/tokens.json")
if err != nil {
// Yes, it is unix-only, but function above rarely fails, so this block is probably never reached.
path := "/home/" + os.Getenv("HOME") + "/.local/share/mycorrhiza/tokens.json"
os.MkdirAll(path, 0777)
return path
log.Fatal(err)
}
if strings.HasPrefix(dir, util.WikiDir) {
log.Fatal("Error: Wiki storage directory includes private config files")
}
return dir
}