Browse Source

Move stats.json to data dir

pull/359/head
Gabe Kangas 5 years ago
parent
commit
934285c55b
  1. 1
      config/constants.go
  2. 10
      core/stats.go

1
config/constants.go

@ -7,6 +7,7 @@ const ( @@ -7,6 +7,7 @@ const (
PrivateHLSStoragePath = "hls"
GeoIPDatabasePath = "data/GeoLite2-City.mmdb"
ExtraInfoFile = "data/content.md"
StatsFile = "data/stats.json"
)
var (

10
core/stats.go

@ -17,10 +17,6 @@ import ( @@ -17,10 +17,6 @@ import (
"github.com/owncast/owncast/utils"
)
const (
statsFilePath = "stats.json"
)
var l = sync.Mutex{}
func setupStats() error {
@ -116,7 +112,7 @@ func saveStatsToFile() error { @@ -116,7 +112,7 @@ func saveStatsToFile() error {
return err
}
f, err := os.Create(statsFilePath)
f, err := os.Create(config.StatsFile)
if err != nil {
return err
}
@ -135,11 +131,11 @@ func getSavedStats() (models.Stats, error) { @@ -135,11 +131,11 @@ func getSavedStats() (models.Stats, error) {
Clients: make(map[string]models.Client),
}
if !utils.DoesFileExists(statsFilePath) {
if !utils.DoesFileExists(config.StatsFile) {
return result, nil
}
jsonFile, err := ioutil.ReadFile(statsFilePath)
jsonFile, err := ioutil.ReadFile(config.StatsFile)
if err != nil {
return result, nil
}

Loading…
Cancel
Save