aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2019-04-13 22:48:51 +0200
committerPřemysl Janouch <p@janouch.name>2019-04-13 22:48:51 +0200
commitf5790dbff9cec6d3fbd09952ba5453ef7a13baf9 (patch)
treea15ecc47719717d72a3da2a8f309e8f1f77dd720
parent401ed713238fff93f7f9c14037df8edf9da7c0c6 (diff)
downloadsklad-f5790dbff9cec6d3fbd09952ba5453ef7a13baf9.tar.gz
sklad-f5790dbff9cec6d3fbd09952ba5453ef7a13baf9.tar.xz
sklad-f5790dbff9cec6d3fbd09952ba5453ef7a13baf9.zip
sklad: write timestamps to the DB log
-rw-r--r--sklad/db.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/sklad/db.go b/sklad/db.go
index 7893ac4..8710fb5 100644
--- a/sklad/db.go
+++ b/sklad/db.go
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"os"
+ "time"
)
type Series struct {
@@ -51,9 +52,14 @@ var (
// TODO: A function for fulltext search in containers (1. Id, 2. Description).
func dbCommit() error {
- // Back up the current database contents.
+ // Write a timestamp.
e := json.NewEncoder(dbLog)
e.SetIndent("", " ")
+ if err := e.Encode(time.Now().Format(time.RFC3339)); err != nil {
+ return err
+ }
+
+ // Back up the current database contents.
if err := e.Encode(&dbLast); err != nil {
return err
}
@@ -128,6 +134,7 @@ func loadDatabase() error {
}
// Validate that no container is a parent of itself on any level.
+ // This could probably be optimized but it would stop being obvious.
for _, pv := range db.Containers {
parents := map[ContainerId]bool{pv.Id(): true}
for pv.Parent != "" {