From d86993857c5e4a33bec6f729baf0cfdc1854ebe4 Mon Sep 17 00:00:00 2001 From: Martin Tournoij Date: Wed, 16 Feb 2022 19:15:17 +0100 Subject: [PATCH] Selecting from languages on startup shouldn't be a fatal error Fixes #570 --- cmd/goatcounter/main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/goatcounter/main.go b/cmd/goatcounter/main.go index 2cda0f4af..de7b4dcf6 100644 --- a/cmd/goatcounter/main.go +++ b/cmd/goatcounter/main.go @@ -194,10 +194,11 @@ func connectDB(connect string, migrate []string, create, dev bool) (zdb.DB, cont // Load languages. var c int err = db.Get(context.Background(), &c, `select count(*) from languages`) - if err != nil { - return nil, nil, err - } - if c == 0 { + // Ignore the error intentionally; not being able to select from the + // languages table here to populate it (usually because it doesn't exist + // yet) shouldn't be a fatal error. If there's some other error then the + // query error will show that one anyway. + if err == nil && c == 0 { langs, err := fs.ReadFile(goatcounter.DB, "db/languages.sql") if err != nil { return nil, nil, err