Maybe fix dumplogs? Not sure why its crashing
alex wennerberg alex@alexwennerberg.com
Mon, 18 Jan 2021 09:42:04 -0800
M
db.go
→
db.go
@@ -24,7 +24,7 @@ }
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 @@ path TEXT,
method TEXT, referer TEXT );`) - if err != nil { - log.Fatal(err) - } - return db + return db, err } type File struct { // also folders
M
log.go
→
log.go
@@ -237,10 +237,14 @@ }
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