Skip to content

Commit b687553

Browse files
authored
pdp/ipni: fix query syntax (#798)
Signed-off-by: Jakub Sztandera <[email protected]>
1 parent 344e82a commit b687553

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

tasks/indexing/task_pdp_ipni.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ func (P *PDPIPNITask) Do(taskID harmonytask.TaskID, stillOwned func() bool) (don
9090

9191
task := tasks[0]
9292

93-
var alreadyPublished bool
94-
err = P.db.QueryRow(ctx, `SELECT is_rm FROM ipni WHERE piece_cid = $1 AND piece_size = $2 ORDER BY order_number DESC LIMIT 1)`, task.PieceCID, task.Size).Scan(&alreadyPublished)
95-
if err != nil {
93+
var isRm bool
94+
err = P.db.QueryRow(ctx, `SELECT is_rm FROM ipni WHERE piece_cid = $1 AND piece_size = $2 ORDER BY order_number DESC LIMIT 1`, task.PieceCID, task.Size).Scan(&isRm)
95+
exists := err == nil
96+
if err != nil && !errors.Is(err, pgx.ErrNoRows) {
9697
return false, xerrors.Errorf("checking if piece is already published: %w", err)
9798
}
9899

99-
if alreadyPublished {
100+
if exists && !isRm {
100101
log.Infow("IPNI task already published", "task_id", taskID, "piece_cid", task.PieceCID)
101102
return true, nil
102103
}

0 commit comments

Comments
 (0)