Merge pull request #6669 from ipfs/fix/6648

pin: fix pin update X Y where X==Y
This commit is contained in:
Steven Allen 2019-09-23 17:12:10 -07:00 committed by GitHub
commit 6e1e6db949
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -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()

View File

@ -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"
'
}