summary refs log tree commit diff stats
path: root/svc
diff options
context:
space:
mode:
authorBen Morrison <ben@gbmor.dev>2019-06-11 00:37:26 -0400
committerBen Morrison <ben@gbmor.dev>2019-06-11 04:54:47 -0400
commit40357b7bc536665812adc51998ecc00d725f2aaf (patch)
treea56853d9a6cc88a302f1f1b4ffa2fb4c2ece9e30 /svc
parentf02cb61da3370e113796dad83eaedcd577f0278a (diff)
downloadgetwtxt-40357b7bc536665812adc51998ecc00d725f2aaf.tar.gz
dbSqlite.Push() now updating confObj.LastPush; dbSqlite.Push() and dbSqlite.Pull() now expecting pointer receiver only
Diffstat (limited to 'svc')
-rw-r--r--svc/sqlite.go13
1 files changed, 8 insertions, 5 deletions
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()
06-05 00:12:52 -0400 moved db test funcs to db_test.go' href='/gbmor/getwtxt/commit/db_test.go?h=v0.4.13&id=35e31f00e82762aec1d849d691f28b534214201d'>35e31f0 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90