From 40357b7bc536665812adc51998ecc00d725f2aaf Mon Sep 17 00:00:00 2001 From: Ben Morrison Date: Tue, 11 Jun 2019 00:37:26 -0400 Subject: dbSqlite.Push() now updating confObj.LastPush; dbSqlite.Push() and dbSqlite.Pull() now expecting pointer receiver only --- svc/sqlite.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'svc') diff --git a/svc/sqlite.go b/svc/sqlite.go index fe9622c..40a7ff2 100644 --- a/svc/sqlite.go +++ b/svc/sqlite.go @@ -42,10 +42,13 @@ func initSqlite() *dbSqlite { } } -func (lite dbSqlite) push() error { - err := lite.db.Ping() - if err != nil { - return err +func (lite *dbSqlite) push() error { + confObj.Mu.Lock() + confObj.LastPush = time.Now() + confObj.Mu.Unlock() + + if err := lite.db.Ping(); err != nil { + lite = initSqlite() } tx, err := lite.db.Begin() @@ -90,7 +93,7 @@ func (lite dbSqlite) push() error { return nil } -func (lite dbSqlite) pull() { +func (lite *dbSqlite) pull() { errLog("Error pinging sqlite DB: ", lite.db.Ping()) rows, err := lite.pullStmt.Query() -- cgit 1.4.1-2-gfad0