Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pin: fix pin update X Y where X==Y #6669

Merged
merged 1 commit into from
Sep 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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