diff --git a/http/notification_rule.go b/http/notification_rule.go index 79e96785de..67a8c3426c 100644 --- a/http/notification_rule.go +++ b/http/notification_rule.go @@ -404,7 +404,7 @@ func decodeNotificationRuleFilter(ctx context.Context, r *http.Request) (*influx } f.OrgID = orgID } else if orgNameStr := q.Get("org"); orgNameStr != "" { - *f.Organization = orgNameStr + f.Organization = &orgNameStr } for _, tag := range q["tag"] { diff --git a/sqlite/sqlite.go b/sqlite/sqlite.go index bf97527364..8176b9fd77 100644 --- a/sqlite/sqlite.go +++ b/sqlite/sqlite.go @@ -9,6 +9,8 @@ import ( "path/filepath" "sync" + errors2 "github.com/influxdata/influxdb/v2/pkg/errors" + "github.com/influxdata/influxdb/v2/kit/tracing" "github.com/influxdata/influxdb/v2/pkg/fs" sqliteMigrations "github.com/influxdata/influxdb/v2/sqlite/migrations" @@ -120,7 +122,7 @@ func (s *SqlStore) Flush(ctx context.Context) { // is the resulting backup. The underlying sqlite connection is needed for both // SOURCE and DESTINATION databases to use the sqlite backup API made available by the // go-sqlite3 driver. -func (s *SqlStore) BackupSqlStore(ctx context.Context, w io.Writer) error { +func (s *SqlStore) BackupSqlStore(ctx context.Context, w io.Writer) (rErr error) { span, _ := tracing.StartSpanFromContext(ctx) defer span.Finish() @@ -136,6 +138,7 @@ func (s *SqlStore) BackupSqlStore(ctx context.Context, w io.Writer) error { if err != nil { return err } + defer errors2.Capture(&rErr, dest.Close) if err := backup(ctx, dest, s); err != nil { return err @@ -211,7 +214,7 @@ func sqliteFromSqlConn(c *sql.Conn) (*sqlite3.SQLiteConn, error) { } // RestoreSqlStore replaces the underlying database with the data from r. -func (s *SqlStore) RestoreSqlStore(ctx context.Context, r io.Reader) error { +func (s *SqlStore) RestoreSqlStore(ctx context.Context, r io.Reader) (rErr error) { tempDir, err := os.MkdirTemp("", "") if err != nil { return err @@ -224,13 +227,16 @@ func (s *SqlStore) RestoreSqlStore(ctx context.Context, r io.Reader) error { if err != nil { return err } + defer errors2.Capture(&rErr, f.Close) // Copy the contents of r to the temporary file if _, err := io.Copy(f, r); err != nil { return err - } else if err := f.Sync(); err != nil { + } + if err := f.Sync(); err != nil { return err - } else if err := f.Close(); err != nil { + } + if err := f.Close(); err != nil { return err }