1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-25 06:58:18 +08:00

Merge pull request #5265 from ipfs/fix/4999

pin update fixes
This commit is contained in:
Whyrusleeping
2018-07-30 09:55:40 -07:00
committed by GitHub
2 changed files with 27 additions and 6 deletions

View File

@ -13,14 +13,13 @@ import (
corerepo "github.com/ipfs/go-ipfs/core/corerepo"
pin "github.com/ipfs/go-ipfs/pin"
uio "github.com/ipfs/go-ipfs/unixfs/io"
bserv "gx/ipfs/QmNqRBAhovtf4jVd5cF7YvHaFSsQHHZBaUFwGQWPM2CV7R/go-blockservice"
"gx/ipfs/QmQwgv79RHrRnoXmhnpC1BPtY55HHeneGMpPwmmBU1fUAG/go-verifcid"
dag "gx/ipfs/QmRy4Qk9hbgFX9NGJRm8rBThrA8PZhNCitMgeRYyZ67s59/go-merkledag"
offline "gx/ipfs/QmS6mo1dPpHdYsVkm27BRZDLxpKBCiJKUH8fHX15XFfMez/go-ipfs-exchange-offline"
path "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path"
resolver "gx/ipfs/QmYKNMEUK7nCVAefgXF1LVtZEZg3uRmBqiae4FJRXDNAyJ/go-path/resolver"
u "gx/ipfs/QmPdKqUcHGFdeSpvjVoaTRPPstGif9GBZb5Q56RVw9o69A/go-ipfs-util"
"gx/ipfs/QmQwgv79RHrRnoXmhnpC1BPtY55HHeneGMpPwmmBU1fUAG/go-verifcid"
offline "gx/ipfs/QmS6mo1dPpHdYsVkm27BRZDLxpKBCiJKUH8fHX15XFfMez/go-ipfs-exchange-offline"
cid "gx/ipfs/QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP/go-cid"
"gx/ipfs/QmdE4gMduCKCGAcczM2F5ioYDfdeKuPix138wrES1YSr7f/go-ipfs-cmdkit"
)
@ -412,13 +411,23 @@ new pin and removing the old one.
return
}
err = n.Pinning.Flush()
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
}
res.SetOutput(&PinOutput{Pins: []string{from.String(), to.String()}})
},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) (io.Reader, error) {
added, ok := res.Output().(*PinOutput)
v, err := unwrapOutput(res.Output())
if err != nil {
return nil, err
}
added, ok := v.(*PinOutput)
if !ok {
return nil, u.ErrCast()
return nil, e.TypeErr(added, v)
}
buf := new(bytes.Buffer)

View File

@ -48,6 +48,18 @@ test_pins() {
test_expect_success "unpin those hashes" '
cat hashes | ipfs pin rm
'
test_expect_success "test pin update" '
ipfs pin add "$HASH_A" &&
ipfs pin ls > before_update &&
test_should_contain "$HASH_A" before_update &&
test_must_fail grep -q "$HASH_B" before_update &&
ipfs pin update --unpin=true "$HASH_A" "$HASH_B" &&
ipfs pin ls > after_update &&
test_must_fail grep -q "$HASH_A" after_update &&
test_should_contain "$HASH_B" after_update &&
ipfs pin rm "$HASH_B"
'
}
RANDOM_HASH=Qme8uX5n9hn15pw9p6WcVKoziyyC9LXv4LEgvsmKMULjnV