From dff85e9c71efad812d92410dad56d6ab7c13c67c Mon Sep 17 00:00:00 2001 From: chrislu Date: Wed, 12 Oct 2022 00:03:14 -0700 Subject: [PATCH] fix error handling --- weed/filer/sqlite/sqlite_store.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/weed/filer/sqlite/sqlite_store.go b/weed/filer/sqlite/sqlite_store.go index 2bacf051a..202834fa2 100644 --- a/weed/filer/sqlite/sqlite_store.go +++ b/weed/filer/sqlite/sqlite_store.go @@ -63,9 +63,11 @@ func (store *SqliteStore) initialize(dbFile, createTable, upsertQuery string) (e var dbErr error store.DB, dbErr = sql.Open("sqlite", dbFile) if dbErr != nil { - store.DB.Close() - store.DB = nil - return fmt.Errorf("can not connect to %s error:%v", dbFile, err) + if store.DB != nil { + store.DB.Close() + store.DB = nil + } + return fmt.Errorf("can not connect to %s error:%v", dbFile, dbErr) } if err = store.DB.Ping(); err != nil {