update clients.json path

This commit is contained in:
shoopea 2021-10-26 22:24:14 +08:00
parent d01c975f5a
commit 0293295a36
2 changed files with 6 additions and 6 deletions

View File

@ -15,14 +15,14 @@ import (
func loadClients() error {
var clts []ChirpClient
b, err := ioutil.ReadFile("./clients.json")
logOnError(err, "loadClients : ReadFile(./clients.json)")
b, err := ioutil.ReadFile("./data/clients.json")
logOnError(err, "loadClients : ReadFile(./data/clients.json)")
if err != nil {
return err
}
err = json.Unmarshal(b, &clts)
logOnError(err, "loadClients : Unmarshal(./clients.json)")
logOnError(err, "loadClients : Unmarshal(./data/clients.json)")
if err != nil {
return err
}

View File

@ -133,13 +133,13 @@ func cronSaveClients() {
pb := pretty.Pretty(b)
err = ioutil.WriteFile("./clients_new.json", pb, 0644)
err = ioutil.WriteFile("./data/clients_new.json", pb, 0644)
logOnError(err, "cronSaveClients : WriteFile")
err = os.Remove("./clients.json")
err = os.Remove("./data/clients.json")
logOnError(err, "cronSaveClients : Remove")
err = os.Rename("./clients_new.json", "./clients.json")
err = os.Rename("./data/clients_new.json", "./data/clients.json")
logOnError(err, "cronSaveClients : Rename")
}