aboutsummaryrefslogtreecommitdiff
path: root/yamldb
diff options
context:
space:
mode:
authorbodqhrohro <bodqhrohro@gmail.com>2019-11-19 23:25:14 +0300
committerbodqhrohro <bodqhrohro@gmail.com>2019-11-19 23:25:14 +0300
commitf0c0d0ba94c923ca06b49211c70db47616e5a8e1 (patch)
tree23c097b6cb8249d4f978f7b22bd1b9877b0a5bba /yamldb
parenta09817976ee5cdb7d1bca25c80cdef3d1b7867f7 (diff)
Save sessions on exit
Diffstat (limited to 'yamldb')
-rw-r--r--yamldb/yamldb.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/yamldb/yamldb.go b/yamldb/yamldb.go
index 1478cc7..76a8292 100644
--- a/yamldb/yamldb.go
+++ b/yamldb/yamldb.go
@@ -30,13 +30,16 @@ func (db *YamlDB) Transaction(callback func() bool, marshaller func() ([]byte, e
if isDataChanged {
yamlData, err := marshaller()
+ log.Debugf("Marshalled YAML: %#v", string(yamlData))
if err != nil {
return errors.Wrap(err, "Data marshalling error")
}
+
err = ioutil.WriteFile(db.PathNew, yamlData, 0644)
if err != nil {
return errors.Wrap(err, "YamlDB write failure")
}
+
err = os.Rename(db.PathNew, db.Path)
if err != nil {
return errors.Wrap(err, "Couldn't rewrite an old YamlDB file")