fix(downloadclient): could not delete (#1020)

* fix(downloadclient): could not delete client

* fix(downloadclient): postgres fix tx options
This commit is contained in:
ze0s 2023-07-21 20:17:39 +02:00 committed by GitHub
parent 6c2f3a4b2b
commit 1637c6209d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -257,7 +257,7 @@ func (r *DownloadClientRepo) Update(ctx context.Context, client domain.DownloadC
}
func (r *DownloadClientRepo) Delete(ctx context.Context, clientID int) error {
tx, err := r.db.BeginTx(ctx, &sql.TxOptions{Isolation: sql.LevelWriteCommitted})
tx, err := r.db.BeginTx(ctx, &sql.TxOptions{})
if err != nil {
return err
}
@ -323,6 +323,11 @@ func (r *DownloadClientRepo) deleteClientFromAction(ctx context.Context, tx *Tx,
var filterID int
if err = queryBuilder.QueryRowContext(ctx).Scan(&filterID); err != nil {
// this will throw when the client is not connected to any actions
// it is not an error in this case
if errors.Is(err, sql.ErrNoRows) {
return nil
}
return errors.Wrap(err, "error executing query")
}