Skip to content

Commit 6e1e6db

Browse files
authored
Merge pull request #6669 from ipfs/fix/6648
pin: fix pin update X Y where X==Y
2 parents 2062738 + 6722a38 commit 6e1e6db

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

pin/pin.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,14 @@ func (p *pinner) RecursiveKeys() []cid.Cid {
516516
// this is more efficient than simply pinning the new one and unpinning the
517517
// old one
518518
func (p *pinner) Update(ctx context.Context, from, to cid.Cid, unpin bool) error {
519+
if from == to {
520+
// Nothing to do. Don't remove this check or we'll end up
521+
// _removing_ the pin.
522+
//
523+
// See #6648
524+
return nil
525+
}
526+
519527
p.lock.Lock()
520528
defer p.lock.Unlock()
521529

test/sharness/t0085-pins.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ test_pins() {
101101
ipfs pin ls $LS_ARGS $BASE_ARGS > after_update &&
102102
test_must_fail grep -q "$HASH_A" after_update &&
103103
test_should_contain "$HASH_B" after_update &&
104+
ipfs pin update --unpin=true "$HASH_B" "$HASH_B" &&
105+
ipfs pin ls $LS_ARGS $BASE_ARGS > after_idempotent_update &&
106+
test_should_contain "$HASH_B" after_idempotent_update &&
104107
ipfs pin rm "$HASH_B"
105108
'
106109
}

0 commit comments

Comments
 (0)