|
| 1 | +From 638b0c4f1b013379a8c2d235a32e5d0ce6c103bb Mon Sep 17 00:00:00 2001 |
| 2 | +From: Joonas Koivunen < [email protected]> |
| 3 | +Date: Sat, 18 Apr 2020 15:15:41 +0300 |
| 4 | +Subject: [PATCH] fix: allow either cidv{0,1} in refs-local test |
| 5 | + |
| 6 | +rationale: simplest way to support using cidv0 and cidv1 interchangeably |
| 7 | +in an ipfs implementation is to just convert all cids to cidv1 |
| 8 | +transparently. this has the miniscule setback of `refs/local` not being able |
| 9 | +to list cids in their original version. this fix allows the |
| 10 | +implementation to use either version internally. |
| 11 | +--- |
| 12 | + packages/interface-ipfs-core/src/refs-local.js | 13 +++++++++---- |
| 13 | + 1 file changed, 9 insertions(+), 4 deletions(-) |
| 14 | + |
| 15 | +diff --git a/packages/interface-ipfs-core/src/refs-local.js b/packages/interface-ipfs-core/src/refs-local.js |
| 16 | +index 78d004de..6628ba8b 100644 |
| 17 | +--- a/packages/interface-ipfs-core/src/refs-local.js |
| 18 | ++++ b/packages/interface-ipfs-core/src/refs-local.js |
| 19 | +@@ -48,12 +48,17 @@ module.exports = (common, options) => { |
| 20 | + |
| 21 | + const imported = await all(importer(dirs, ipfs.block)) |
| 22 | + |
| 23 | +- // otherwise go-ipfs doesn't show them in the local refs |
| 24 | +- await Promise.all( |
| 25 | +- imported.map(i => ipfs.pin.add(i.cid)) |
| 26 | +- ) |
| 27 | ++ // rust-ipfs doesn't yet have pinning api, it'll just list all local cids |
| 28 | ++ // in /refs/local |
| 29 | ++ if (common.opts.type !== 'rust') { |
| 30 | ++ // otherwise go-ipfs doesn't show them in the local refs |
| 31 | ++ await Promise.all( |
| 32 | ++ imported.map(i => ipfs.pin.add(i.cid)) |
| 33 | ++ ) |
| 34 | ++ } |
| 35 | + |
| 36 | + const refs = await all(ipfs.refs.local()) |
| 37 | ++ |
| 38 | + const cids = refs.map(r => r.ref) |
| 39 | + |
| 40 | + expect( |
| 41 | +-- |
| 42 | +2.20.1 |
| 43 | + |
0 commit comments