all repos — flounder @ 25aaf338f943415e1cb5b5a35c26b983b5b2d815

A small site builder for the Gemini protocol

Maybe fix dumplogs? Not sure why its crashing
alex wennerberg alex@alexwennerberg.com
Mon, 18 Jan 2021 09:42:04 -0800
commit

25aaf338f943415e1cb5b5a35c26b983b5b2d815

parent

a3401dc4b886761ec2ee7d083f62ee572debd97f

2 files changed, 8 insertions(+), 7 deletions(-)

jump to
M db.godb.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.golog.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