mirror of
https://github.com/sablierapp/sablier.git
synced 2025-12-21 13:23:03 +01:00
fix(storage): initialize file to an empty JSON
It will avoir error message like `time="2022-11-14T01:40:49Z" level=error msg="error loading sessionsEOF"`
This commit is contained in:
@@ -33,6 +33,16 @@ func NewFileStorage(config config.Storage) (Storage, error) {
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
stats, err := file.Stat()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Initialize file to an empty JSON3
|
||||
if stats.Size() == 0 {
|
||||
file.WriteString("{}")
|
||||
}
|
||||
|
||||
log.Infof("initialized storage to %s", config.File)
|
||||
} else {
|
||||
log.Warn("no storage configuration provided. all states will be lost upon exit")
|
||||
|
||||
@@ -189,7 +189,6 @@
|
||||
time="2022-11-14T01:40:49Z" level=info msg="(version=1.1.1, branch=HEAD, revision=a913bc2a3b0f4aca5b9ac7ddc9af5428ef411dba)"
|
||||
time="2022-11-14T01:40:49Z" level=info msg="using provider \"kubernetes\""
|
||||
time="2022-11-14T01:40:49Z" level=info msg="initialized storage to /etc/sablier/state.json"
|
||||
time="2022-11-14T01:40:49Z" level=error msg="error loading sessionsEOF"
|
||||
time="2022-11-14T01:40:49Z" level=info msg="server listening :10000"
|
||||
```
|
||||
|
||||
|
||||
Reference in New Issue
Block a user