add database restore/save

This commit is contained in:
Kyle Isom 2023-05-06 00:32:00 -07:00
parent 353cf2cf8a
commit dd3e29860a
1 changed files with 15 additions and 2 deletions

15
main.go
View File

@ -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,9 +48,14 @@ func fetchItems(db *nomad.DB, markOnly bool) error {
}
tx.Commit()
if err := restoreDatabase(config.Get("local_database")); err != nil {
return err
}
return nil
}
client := woodstock.NewClient(config.Get("pnut_id"), config.Get("pnut_secret"))
client.SetAccessToken(config.Get(""))
@ -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)