Skip to content

Commit

Permalink
Merge pull request #6669 from ipfs/fix/6648
Browse files Browse the repository at this point in the history
pin: fix pin update X Y where X==Y
  • Loading branch information
Stebalien committed Sep 24, 2019
2 parents 2062738 + 6722a38 commit 6e1e6db
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pin/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,14 @@ func (p *pinner) RecursiveKeys() []cid.Cid {
// this is more efficient than simply pinning the new one and unpinning the
// old one
func (p *pinner) Update(ctx context.Context, from, to cid.Cid, unpin bool) error {
if from == to {
// Nothing to do. Don't remove this check or we'll end up
// _removing_ the pin.
//
// See #6648
return nil
}

p.lock.Lock()
defer p.lock.Unlock()

Expand Down
3 changes: 3 additions & 0 deletions test/sharness/t0085-pins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ test_pins() {
ipfs pin ls $LS_ARGS $BASE_ARGS > after_update &&
test_must_fail grep -q "$HASH_A" after_update &&
test_should_contain "$HASH_B" after_update &&
ipfs pin update --unpin=true "$HASH_B" "$HASH_B" &&
ipfs pin ls $LS_ARGS $BASE_ARGS > after_idempotent_update &&
test_should_contain "$HASH_B" after_idempotent_update &&
ipfs pin rm "$HASH_B"
'
}
Expand Down

0 comments on commit 6e1e6db

Please sign in to comment.