flounder

A simple gemini site builder
Log | Files | Refs | README | LICENSE

commit 25aaf338f943415e1cb5b5a35c26b983b5b2d815
parent a3401dc4b886761ec2ee7d083f62ee572debd97f
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Mon, 18 Jan 2021 09:42:04 -0800

Maybe fix dumplogs? Not sure why its crashing

Diffstat:
Mdb.go | 7++-----
Mlog.go | 8++++++--
2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/db.go b/db.go @@ -24,7 +24,7 @@ func initializeDB() { createTablesIfDNE() } -func getAnalyticsDB() *sql.DB { +func getAnalyticsDB() (*sql.DB, error) { db, err := sql.Open("sqlite3", c.AnalyticsDBFile) _, err = db.Exec(`CREATE TABLE IF NOT EXISTS log ( id INTEGER PRIMARY KEY NOT NULL, @@ -38,10 +38,7 @@ func getAnalyticsDB() *sql.DB { method TEXT, referer TEXT );`) - if err != nil { - log.Fatal(err) - } - return db + return db, err } type File struct { // also folders diff --git a/log.go b/log.go @@ -237,10 +237,14 @@ func lineToLogLine(line string) (*LogLine, error) { func dumpLogs() { log.Println("Writing missing logs to database") - db := getAnalyticsDB() + db, err := getAnalyticsDB() + if err != nil { + // not perfect -- squashes errors + return + } var maxTime string row := db.QueryRow(`SELECT timestamp from log order by timestamp desc limit 1`) - err := row.Scan(&maxTime) + err = row.Scan(&maxTime) if err != nil { // not perfect -- squashes errors return