Skip to content

High performance, self-hosted, newsletter and mailing list manager with a modern dashboard. Single binary app.

fix: abort idempotent install on non-SQL errors instead of installing (#3196)

Tobias Wiesinga5e9908b4cc7
diff --git a/cmd/install.go b/cmd/install.go
index 1e5926c2..bcffac30 100644
--- a/cmd/install.go
+++ b/cmd/install.go
@@ -45,8 +45,9 @@ func install(lastVer string, db *sqlx.DB, fs stuffbin.FileSystem, prompt, idempo
// If idempotence is on, check if the DB is already setup.
if idempotent {
if _, err := db.Exec("SELECT count(*) FROM settings"); err != nil {
- // If "settings" doesn't exist, assume it's a fresh install.
- if pqErr, ok := err.(*pq.Error); ok && pqErr.Code != "42P01" {
+ // Treat missing "settings" table (42P01) as a fresh install.
+ // Abort on all other errors to not end up in a half-baked state.
+ if !isTableNotExistErr(err) {
lo.Fatalf("error checking existing DB schema: %v", err)
}
} else {