From f0c0d0ba94c923ca06b49211c70db47616e5a8e1 Mon Sep 17 00:00:00 2001 From: bodqhrohro Date: Tue, 19 Nov 2019 22:25:14 +0200 Subject: Save sessions on exit --- yamldb/yamldb.go | 3 +++ 1 file changed, 3 insertions(+) (limited to 'yamldb') 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") -- cgit v1.2.3