sklad: sync the database log

This commit is contained in:
Přemysl Eric Janouch 2019-04-13 05:57:19 +02:00
parent 8c3aaa8261
commit 401ed71323
Signed by: p
GPG Key ID: A0420B94F92B9493
1 changed files with 4 additions and 2 deletions

View File

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io"
"os" "os"
) )
@ -37,7 +36,7 @@ var (
dbPath string dbPath string
db Database db Database
dbLast Database dbLast Database
dbLog io.Writer dbLog *os.File
indexSeries = map[string]*Series{} indexSeries = map[string]*Series{}
indexContainer = map[ContainerId]*Container{} indexContainer = map[ContainerId]*Container{}
@ -58,6 +57,9 @@ func dbCommit() error {
if err := e.Encode(&dbLast); err != nil { if err := e.Encode(&dbLast); err != nil {
return err return err
} }
if err := dbLog.Sync(); err != nil {
return err
}
// Atomically replace the current database file. // Atomically replace the current database file.
tempPath := dbPath + ".new" tempPath := dbPath + ".new"