From 58d075ebaf348a186573db081a09477d55e29955 Mon Sep 17 00:00:00 2001 From: Toni Spets Date: Fri, 26 Jan 2024 07:52:41 +0200 Subject: [PATCH] Fix ReadOnlyDB close error handling --- dbutil/database.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dbutil/database.go b/dbutil/database.go index 0829057..bcaa8ea 100644 --- a/dbutil/database.go +++ b/dbutil/database.go @@ -183,11 +183,12 @@ type Config struct { func (db *Database) Close() error { err := db.RawDB.Close() if db.ReadOnlyDB != nil { - err2 := db.ReadOnlyDB.Close() - if err == nil { - err = fmt.Errorf("closing read-only db failed: %w", err2) - } else { - err = fmt.Errorf("%w (closing read-only db also failed: %v)", err, err2) + if err2 := db.ReadOnlyDB.Close(); err2 != nil { + if err == nil { + err = fmt.Errorf("closing read-only db failed: %w", err2) + } else { + err = fmt.Errorf("%w (closing read-only db also failed: %v)", err, err2) + } } } return err