fix: add missing error handling

This commit is contained in:
Markus Pesch 2021-04-09 16:55:35 +02:00
parent 749f2697c7
commit 9207833a71
Signed by: volker.raschek
GPG Key ID: 852BCC170D81A982
2 changed files with 11 additions and 0 deletions

View File

@ -891,6 +891,10 @@ func (d *Postgres) Import(ctx context.Context, src Repository) error {
}
sensors, err := src.GetSensors(ctx)
if err != nil {
return err
}
err = d.insertOrUpdateSensors(tx, sensors...)
if err != nil {
return err

View File

@ -921,6 +921,9 @@ func (d *SQLite) GetTemperatures(ctx context.Context) ([]*types.MeasuredValue, e
// Import imports devices, sensors and all measured values from a source
// repository. Existing entries will be updated.
func (d *SQLite) Import(ctx context.Context, src Repository) error {
d.mutex.Lock()
defer d.mutex.Unlock()
tx, err := d.dbo.BeginTx(ctx, &sql.TxOptions{ReadOnly: false})
if err != nil {
return err
@ -938,6 +941,10 @@ func (d *SQLite) Import(ctx context.Context, src Repository) error {
}
sensors, err := src.GetSensors(ctx)
if err != nil {
return err
}
err = d.insertOrUpdateSensors(tx, sensors...)
if err != nil {
return err