diff options
author | Přemysl Janouch <p@janouch.name> | 2019-04-13 05:57:19 +0200 |
---|---|---|
committer | Přemysl Janouch <p@janouch.name> | 2019-04-13 05:57:43 +0200 |
commit | 401ed713238fff93f7f9c14037df8edf9da7c0c6 (patch) | |
tree | ec8f016af5d762a5d728ee38172644c2324fd3e0 | |
parent | 8c3aaa8261c9799a01baaafb17d14d88fa3b3457 (diff) | |
download | sklad-401ed713238fff93f7f9c14037df8edf9da7c0c6.tar.gz sklad-401ed713238fff93f7f9c14037df8edf9da7c0c6.tar.xz sklad-401ed713238fff93f7f9c14037df8edf9da7c0c6.zip |
sklad: sync the database log
-rw-r--r-- | sklad/db.go | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/sklad/db.go b/sklad/db.go index c036cb8..7893ac4 100644 --- a/sklad/db.go +++ b/sklad/db.go @@ -4,7 +4,6 @@ import ( "encoding/json" "errors" "fmt" - "io" "os" ) @@ -37,7 +36,7 @@ var ( dbPath string db Database dbLast Database - dbLog io.Writer + dbLog *os.File indexSeries = map[string]*Series{} indexContainer = map[ContainerId]*Container{} @@ -58,6 +57,9 @@ func dbCommit() error { if err := e.Encode(&dbLast); err != nil { return err } + if err := dbLog.Sync(); err != nil { + return err + } // Atomically replace the current database file. tempPath := dbPath + ".new" |