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

fix(pin): wait till after fetching to remove direct pin #6708

Merged
merged 1 commit into from
Oct 8, 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
3 changes: 0 additions & 3 deletions pin/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,6 @@ func (p *pinner) Pin(ctx context.Context, node ipld.Node, recurse bool) error {
return nil
}

if p.directPin.Has(c) {
p.directPin.Remove(c)
}
p.lock.Unlock()
// fetch entire graph
err := mdag.FetchGraph(ctx, c, p.dserv)
Expand Down
10 changes: 9 additions & 1 deletion test/sharness/t0081-repo-pinning.sh
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,21 @@ test_expect_success "some are no longer there" '
test_must_fail ipfs ls "$HASH_DIR3"
'

test_launch_ipfs_daemon --offline
test_expect_success "recursive pin fails without objects" '
ipfs pin rm -r=false "$HASH_DIR1" &&
test_must_fail ipfs pin add -r "$HASH_DIR1" 2>err_expected8 &&
grep "pin: merkledag: not found" err_expected8 ||
test_fsh cat err_expected8
'

# Regression test for https://github.com/ipfs/go-ipfs/issues/4650
# This test requires the daemon. Otherwise, the pin changes are reverted when
# the pin fails in the previous test.
test_expect_success "failed recursive pin does not remove direct pin" '
test_pin_flag "$HASH_DIR1" direct true
'
test_kill_ipfs_daemon

test_expect_success "test add nopin file" '
echo "test nopin data" > test_nopin_data &&
NOPINHASH=$(ipfs add -q --pin=false test_nopin_data) &&
Expand Down