mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-03 23:38:07 +08:00
feat(pinning): allow for overwriting pin name
This commit is contained in:
parent
b215d73e45
commit
8a421868f0
@ -71,10 +71,8 @@ Use 'pin ls -t recursive' to only list roots of recursively pinned DAGs
|
||||
(significantly faster when many big DAGs are pinned recursively)
|
||||
|
||||
Default pin name is empty. Pass '--name' to 'pin add' to set one
|
||||
and use 'pin ls --names' to see it.
|
||||
Pin add is idempotent: pinning CID which is already pinned won't change
|
||||
the name, value passed with '--name' with the original pin is preserved.
|
||||
To rename pin, use 'pin rm' and 'pin add --name'.
|
||||
and use 'pin ls --names' to see it. Pinning a second time with a different
|
||||
name will update the name of the pin.
|
||||
|
||||
If daemon is running, any missing blocks will be retrieved from the network.
|
||||
It may take some time. Pass '--progress' to track the progress.
|
||||
|
||||
@ -7,7 +7,7 @@ go 1.20
|
||||
replace github.com/ipfs/kubo => ./../../..
|
||||
|
||||
require (
|
||||
github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287
|
||||
github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e
|
||||
github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
|
||||
github.com/libp2p/go-libp2p v0.32.2
|
||||
github.com/multiformats/go-multiaddr v0.12.0
|
||||
|
||||
@ -261,8 +261,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
|
||||
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
|
||||
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
|
||||
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287 h1:My5Ct2+5I/+FN2HaFm3VCQB3Y+/A5kcWDGNS0JR1jo8=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e h1:GFMm0GO3tTLmjJ6uNZnTq0HpYV/kygZhe1sKYHQ/aVc=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
|
||||
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
|
||||
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
|
||||
github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
|
||||
|
||||
2
go.mod
2
go.mod
@ -17,7 +17,7 @@ require (
|
||||
github.com/hashicorp/go-multierror v1.1.1
|
||||
github.com/ipfs-shipyard/nopfs v0.0.12-0.20231027223058-cde3b5ba964c
|
||||
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c
|
||||
github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287
|
||||
github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e
|
||||
github.com/ipfs/go-block-format v0.2.0
|
||||
github.com/ipfs/go-cid v0.4.1
|
||||
github.com/ipfs/go-cidutil v0.1.0
|
||||
|
||||
4
go.sum
4
go.sum
@ -325,8 +325,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
|
||||
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
|
||||
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
|
||||
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287 h1:My5Ct2+5I/+FN2HaFm3VCQB3Y+/A5kcWDGNS0JR1jo8=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e h1:GFMm0GO3tTLmjJ6uNZnTq0HpYV/kygZhe1sKYHQ/aVc=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
|
||||
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
|
||||
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
|
||||
github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ=
|
||||
|
||||
@ -210,6 +210,10 @@ func TestPins(t *testing.T) {
|
||||
testPins(t, testPinsArgs{runDaemon: true, lsArg: "--stream", baseArg: "--cid-base=base32"})
|
||||
})
|
||||
|
||||
pinLs := func(node *harness.Node, args ...string) []string {
|
||||
return strings.Split(node.IPFS(StrCat("pin", "ls", args)...).Stdout.Trimmed(), "\n")
|
||||
}
|
||||
|
||||
t.Run("test pinning with names cli text output", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@ -224,24 +228,40 @@ func TestPins(t *testing.T) {
|
||||
outBRegular := cidBStr + " recursive"
|
||||
outBDetailed := outBRegular + " testPin"
|
||||
|
||||
pinLs := func(args ...string) []string {
|
||||
return strings.Split(node.IPFS(StrCat("pin", "ls", args)...).Stdout.Trimmed(), "\n")
|
||||
}
|
||||
|
||||
lsOut := pinLs("-t=recursive")
|
||||
lsOut := pinLs(node, "-t=recursive")
|
||||
require.Contains(t, lsOut, outARegular)
|
||||
require.NotContains(t, lsOut, outADetailed)
|
||||
|
||||
lsOut = pinLs("-t=recursive", "--names")
|
||||
lsOut = pinLs(node, "-t=recursive", "--names")
|
||||
require.Contains(t, lsOut, outADetailed)
|
||||
require.NotContains(t, lsOut, outARegular)
|
||||
|
||||
_ = node.IPFS("pin", "update", cidAStr, cidBStr)
|
||||
lsOut = pinLs("-t=recursive", "--names")
|
||||
lsOut = pinLs(node, "-t=recursive", "--names")
|
||||
require.Contains(t, lsOut, outBDetailed)
|
||||
require.NotContains(t, lsOut, outADetailed)
|
||||
})
|
||||
|
||||
t.Run("test overwriting pin with name", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
node := harness.NewT(t).NewNode().Init()
|
||||
cidStr := node.IPFSAddStr(RandomStr(1000), "--pin=false")
|
||||
|
||||
outBefore := cidStr + " recursive A"
|
||||
outAfter := cidStr + " recursive B"
|
||||
|
||||
_ = node.IPFS("pin", "add", "--name", "A", cidStr)
|
||||
lsOut := pinLs(node, "-t=recursive", "--names")
|
||||
require.Contains(t, lsOut, outBefore)
|
||||
require.NotContains(t, lsOut, outAfter)
|
||||
|
||||
_ = node.IPFS("pin", "add", "--name", "B", cidStr)
|
||||
lsOut = pinLs(node, "-t=recursive", "--names")
|
||||
require.Contains(t, lsOut, outAfter)
|
||||
require.NotContains(t, lsOut, outBefore)
|
||||
})
|
||||
|
||||
// JSON that is also the wire format of /api/v0
|
||||
t.Run("test pinning with names json output", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@ -103,7 +103,7 @@ require (
|
||||
github.com/hexops/gotextdiff v1.0.3 // indirect
|
||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
||||
github.com/ipfs/bbloom v0.0.4 // indirect
|
||||
github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287 // indirect
|
||||
github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e // indirect
|
||||
github.com/ipfs/go-block-format v0.2.0 // indirect
|
||||
github.com/ipfs/go-cid v0.4.1 // indirect
|
||||
github.com/ipfs/go-datastore v0.6.0 // indirect
|
||||
|
||||
@ -342,8 +342,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
|
||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
||||
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
|
||||
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287 h1:My5Ct2+5I/+FN2HaFm3VCQB3Y+/A5kcWDGNS0JR1jo8=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e h1:GFMm0GO3tTLmjJ6uNZnTq0HpYV/kygZhe1sKYHQ/aVc=
|
||||
github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
|
||||
github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs=
|
||||
github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM=
|
||||
github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=
|
||||
|
||||
Loading…
Reference in New Issue
Block a user