update clients.json path
This commit is contained in:
parent
d01c975f5a
commit
0293295a36
@ -15,14 +15,14 @@ import (
|
|||||||
func loadClients() error {
|
func loadClients() error {
|
||||||
var clts []ChirpClient
|
var clts []ChirpClient
|
||||||
|
|
||||||
b, err := ioutil.ReadFile("./clients.json")
|
b, err := ioutil.ReadFile("./data/clients.json")
|
||||||
logOnError(err, "loadClients : ReadFile(./clients.json)")
|
logOnError(err, "loadClients : ReadFile(./data/clients.json)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
err = json.Unmarshal(b, &clts)
|
err = json.Unmarshal(b, &clts)
|
||||||
logOnError(err, "loadClients : Unmarshal(./clients.json)")
|
logOnError(err, "loadClients : Unmarshal(./data/clients.json)")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
6
cron.go
6
cron.go
@ -133,13 +133,13 @@ func cronSaveClients() {
|
|||||||
|
|
||||||
pb := pretty.Pretty(b)
|
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")
|
logOnError(err, "cronSaveClients : WriteFile")
|
||||||
|
|
||||||
err = os.Remove("./clients.json")
|
err = os.Remove("./data/clients.json")
|
||||||
logOnError(err, "cronSaveClients : Remove")
|
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")
|
logOnError(err, "cronSaveClients : Rename")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user