From 97d98ec661ee8f8e7325f2610a40588040487c94 Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Tue, 12 Mar 2024 14:35:55 -0700 Subject: [PATCH] sqlite: ignore duplicate pins --- persist/sqlite/blocks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/persist/sqlite/blocks.go b/persist/sqlite/blocks.go index 0cab8ca..f39e3d9 100644 --- a/persist/sqlite/blocks.go +++ b/persist/sqlite/blocks.go @@ -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) }