@cryptotaxi247 / kubo / commits / 8a421868f

feat(pinning): allow for overwriting pin name

Henrique Dias committed Jan 8, 2024 at 11:43 UTC 8a421868f0e19abaa7d79540d8bee657931bddf4
8 files changed +38 -20
core/commands/pin/pin.go
+2 -4
@@ -71,10 +71,8 @@ Use 'pin ls -t recursive' to only list roots of recursively pinned DAGs
71 (significantly faster when many big DAGs are pinned recursively)
72
73 Default pin name is empty. Pass '--name' to 'pin add' to set one
74 -and use 'pin ls --names' to see it.
75 -Pin add is idempotent: pinning CID which is already pinned won't change
76 -the name, value passed with '--name' with the original pin is preserved.
77 -To rename pin, use 'pin rm' and 'pin add --name'.
74 +and use 'pin ls --names' to see it. Pinning a second time with a different
75 +name will update the name of the pin.
76
77 If daemon is running, any missing blocks will be retrieved from the network.
78 It may take some time. Pass '--progress' to track the progress.
docs/examples/kubo-as-a-library/go.mod
+1 -1
@@ -7,7 +7,7 @@ go 1.20
7 replace github.com/ipfs/kubo => ./../../..
8
9 require (
10 - github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287
10 + github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e
11 github.com/ipfs/kubo v0.0.0-00010101000000-000000000000
12 github.com/libp2p/go-libp2p v0.32.2
13 github.com/multiformats/go-multiaddr v0.12.0
docs/examples/kubo-as-a-library/go.sum
+2 -2
@@ -261,8 +261,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
261 github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
262 github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
263 github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
264 -github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287 h1:My5Ct2+5I/+FN2HaFm3VCQB3Y+/A5kcWDGNS0JR1jo8=
265 -github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
264 +github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e h1:GFMm0GO3tTLmjJ6uNZnTq0HpYV/kygZhe1sKYHQ/aVc=
265 +github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
266 github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
267 github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
268 github.com/ipfs/go-block-format v0.0.2/go.mod h1:AWR46JfpcObNfg3ok2JHDUfdiHRgWhJgCQF+KIgOPJY=
go.mod
+1 -1
@@ -17,7 +17,7 @@ require (
17 github.com/hashicorp/go-multierror v1.1.1
18 github.com/ipfs-shipyard/nopfs v0.0.12-0.20231027223058-cde3b5ba964c
19 github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c
20 - github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287
20 + github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e
21 github.com/ipfs/go-block-format v0.2.0
22 github.com/ipfs/go-cid v0.4.1
23 github.com/ipfs/go-cidutil v0.1.0
go.sum
+2 -2
@@ -325,8 +325,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c h1:7Uy
325 github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231027223058-cde3b5ba964c/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
326 github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
327 github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
328 -github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287 h1:My5Ct2+5I/+FN2HaFm3VCQB3Y+/A5kcWDGNS0JR1jo8=
329 -github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
328 +github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e h1:GFMm0GO3tTLmjJ6uNZnTq0HpYV/kygZhe1sKYHQ/aVc=
329 +github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
330 github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
331 github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
332 github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ=
test/cli/pins_test.go
+27 -7
@@ -210,6 +210,10 @@ func TestPins(t *testing.T) {
210 testPins(t, testPinsArgs{runDaemon: true, lsArg: "--stream", baseArg: "--cid-base=base32"})
211 })
212
213 + pinLs := func(node *harness.Node, args ...string) []string {
214 + return strings.Split(node.IPFS(StrCat("pin", "ls", args)...).Stdout.Trimmed(), "\n")
215 + }
216 +
217 t.Run("test pinning with names cli text output", func(t *testing.T) {
218 t.Parallel()
219
@@ -224,24 +228,40 @@ func TestPins(t *testing.T) {
228 outBRegular := cidBStr + " recursive"
229 outBDetailed := outBRegular + " testPin"
230
227 - pinLs := func(args ...string) []string {
228 - return strings.Split(node.IPFS(StrCat("pin", "ls", args)...).Stdout.Trimmed(), "\n")
229 - }
230 -
231 - lsOut := pinLs("-t=recursive")
231 + lsOut := pinLs(node, "-t=recursive")
232 require.Contains(t, lsOut, outARegular)
233 require.NotContains(t, lsOut, outADetailed)
234
235 - lsOut = pinLs("-t=recursive", "--names")
235 + lsOut = pinLs(node, "-t=recursive", "--names")
236 require.Contains(t, lsOut, outADetailed)
237 require.NotContains(t, lsOut, outARegular)
238
239 _ = node.IPFS("pin", "update", cidAStr, cidBStr)
240 - lsOut = pinLs("-t=recursive", "--names")
240 + lsOut = pinLs(node, "-t=recursive", "--names")
241 require.Contains(t, lsOut, outBDetailed)
242 require.NotContains(t, lsOut, outADetailed)
243 })
244
245 + t.Run("test overwriting pin with name", func(t *testing.T) {
246 + t.Parallel()
247 +
248 + node := harness.NewT(t).NewNode().Init()
249 + cidStr := node.IPFSAddStr(RandomStr(1000), "--pin=false")
250 +
251 + outBefore := cidStr + " recursive A"
252 + outAfter := cidStr + " recursive B"
253 +
254 + _ = node.IPFS("pin", "add", "--name", "A", cidStr)
255 + lsOut := pinLs(node, "-t=recursive", "--names")
256 + require.Contains(t, lsOut, outBefore)
257 + require.NotContains(t, lsOut, outAfter)
258 +
259 + _ = node.IPFS("pin", "add", "--name", "B", cidStr)
260 + lsOut = pinLs(node, "-t=recursive", "--names")
261 + require.Contains(t, lsOut, outAfter)
262 + require.NotContains(t, lsOut, outBefore)
263 + })
264 +
265 // JSON that is also the wire format of /api/v0
266 t.Run("test pinning with names json output", func(t *testing.T) {
267 t.Parallel()
test/dependencies/go.mod
+1 -1
@@ -103,7 +103,7 @@ require (
103 github.com/hexops/gotextdiff v1.0.3 // indirect
104 github.com/inconshreveable/mousetrap v1.1.0 // indirect
105 github.com/ipfs/bbloom v0.0.4 // indirect
106 - github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287 // indirect
106 + github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e // indirect
107 github.com/ipfs/go-block-format v0.2.0 // indirect
108 github.com/ipfs/go-cid v0.4.1 // indirect
109 github.com/ipfs/go-datastore v0.6.0 // indirect
test/dependencies/go.sum
+2 -2
@@ -342,8 +342,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2
342 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
343 github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
344 github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
345 -github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287 h1:My5Ct2+5I/+FN2HaFm3VCQB3Y+/A5kcWDGNS0JR1jo8=
346 -github.com/ipfs/boxo v0.16.1-0.20240104131845-a391d0210287/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
345 +github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e h1:GFMm0GO3tTLmjJ6uNZnTq0HpYV/kygZhe1sKYHQ/aVc=
346 +github.com/ipfs/boxo v0.16.1-0.20240109085802-d13d712f1c4e/go.mod h1:gCYL6EViui01M8Dr0cY8nOpRAbofxZDWASxbLSrG9Ac=
347 github.com/ipfs/go-block-format v0.2.0 h1:ZqrkxBA2ICbDRbK8KJs/u0O3dlp6gmAuuXUJNiW1Ycs=
348 github.com/ipfs/go-block-format v0.2.0/go.mod h1:+jpL11nFx5A/SPpsoBn6Bzkra/zaArfSmsknbPMYgzM=
349 github.com/ipfs/go-cid v0.4.1 h1:A/T3qGvxi4kpKWWcPC/PgbvDA2bjVLO7n4UeVwnbs/s=