From dd3e29860aa90337672533ffd778274e1f17202f Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Sat, 6 May 2023 00:32:00 -0700 Subject: [PATCH] add database restore/save --- main.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index b729ebb..1fd8c70 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ import ( var defaultRSS = "https://nomad.wntrmute.net/u/kyle.rss" func defaultPath(file string) string { - return filepath.Join("/perm", "nlink", file) + return filepath.Join("/etc", "nlink", file) } func fetchItems(db *nomad.DB, markOnly bool) error { @@ -48,7 +48,12 @@ func fetchItems(db *nomad.DB, markOnly bool) error { } tx.Commit() - return err + + if err := restoreDatabase(config.Get("local_database")); err != nil { + return err + } + + return nil } client := woodstock.NewClient(config.Get("pnut_id"), config.Get("pnut_secret")) @@ -65,6 +70,10 @@ func fetchItems(db *nomad.DB, markOnly bool) error { err = db.Mark(nil, item) } + if err := restoreDatabase(config.Get("local_database")); err != nil { + log.Err(err) + } + return nil } @@ -96,6 +105,10 @@ func main() { die.If(err) } + if err := restoreDatabase(config.Get("local_database")); err != nil { + log.Fatal(err) + } + log.Debugf("loading config file %s", configFile) if err := config.LoadFile(configFile); err != nil { log.Fatal(err)