Skip to content

Commit

Permalink
sqlite: ignore duplicate pins
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Mar 12, 2024
1 parent c5647d0 commit 97d98ec
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion persist/sqlite/blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *Store) Pin(b renterd.PinnedBlock) error {
return fmt.Errorf("failed to insert block: %w", err)
}

_, err = tx.Exec(`INSERT INTO pinned_blocks (block_id, renterd_bucket, renterd_object_key) VALUES ($1, $2, $3)`, parentBlockID, b.Bucket, b.ObjectKey)
_, err = tx.Exec(`INSERT INTO pinned_blocks (block_id, renterd_bucket, renterd_object_key) VALUES ($1, $2, $3) ON CONFLICT (block_id) DO NOTHING`, parentBlockID, b.Bucket, b.ObjectKey)
if err != nil {
return fmt.Errorf("failed to insert pinned block: %w", err)
}
Expand Down

0 comments on commit 97d98ec

Please sign in to comment.