-
Notifications
You must be signed in to change notification settings - Fork 1
feat!: rename, update, test, type, and ready for launch #2
base: main
Are you sure you want to change the base?
Conversation
Upgrade this lib so we can use it for extracting paths all over the place (dagula, freeway, etc) License: MIT Signed-off-by: Oli Evans <[email protected]>
License: MIT Signed-off-by: Oli Evans <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 Amazing! Feedback is all non blocking apart from the double block yield one.
cli.js
Outdated
.option('-o, --output', 'Output path for CAR') | ||
.action(async (path, car, options) => { | ||
console.log({ path, car, options }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
console.log({ path, car, options }) |
package.json
Outdated
"version": "1.1.0", | ||
"description": "Extract UnixFS paths from an existing DAG with merkle proofs.", | ||
"description": "Extract blocks for a UnixFS paths from a DAG", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"description": "Extract blocks for a UnixFS paths from a DAG", | |
"description": "Extract blocks for UnixFS paths from a DAG", |
package.json
Outdated
@@ -41,5 +47,12 @@ | |||
"bugs": { | |||
"url": "https://github.com/alanshaw/ipfs-car-extract/issues" | |||
}, | |||
"homepage": "https://github.com/alanshaw/ipfs-car-extract#readme" | |||
"homepage": "https://github.com/alanshaw/ipfs-car-extract#readme", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"homepage": "https://github.com/alanshaw/ipfs-car-extract#readme", | |
"homepage": "https://github.com/web3-storage/ipfs-path#readme", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and more of these in package.json I cannot suggest for.
@@ -1,37 +1,43 @@ | |||
{ | |||
"name": "ipfs-car-extract", | |||
"name": "@web3-storage/ipfs-path", | |||
"version": "1.1.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe reset to 1.0.0
?
for await (const shardBlock of findShardedBlock(node, part, blockstore)) { | ||
if (lastBlock) yield lastBlock |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is like it is because exportBlocks
yields the block you pass to it, so you want to yield all the intermediate blocks here, but not the last one, otherwise you'll yield it twice.
Alternatively you could switch it round so that exportBlocks
does not yield the root block you pass it, but is maybe a bigger change.
test('cli extract dagPB path', async t => { | ||
const carName = 'extract-me.car' | ||
const outName = 'extracted.car' | ||
t.teardown(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh I did not know this existed...
test.js
Outdated
const fsStream = Readable.from(out).pipe(fs.createWriteStream(carName)) | ||
|
||
for await (const block of readable) { | ||
await carWriter.put(block) | ||
} | ||
|
||
await carWriter.close() | ||
|
||
// wait for car to be written to fs | ||
await new Promise((resolve, reject) => { | ||
if (fsStream.closed) return resolve(true) | ||
fsStream.once('finish', resolve) | ||
fsStream.once('error', reject) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe slightly simplier with pipeline from stream/promises
?:
const fsStream = Readable.from(out).pipe(fs.createWriteStream(carName)) | |
for await (const block of readable) { | |
await carWriter.put(block) | |
} | |
await carWriter.close() | |
// wait for car to be written to fs | |
await new Promise((resolve, reject) => { | |
if (fsStream.closed) return resolve(true) | |
fsStream.once('finish', resolve) | |
fsStream.once('error', reject) | |
}) | |
const carWritten = pipeline(out, fs.createWriteStream(carName)) | |
for await (const block of readable) { | |
await carWriter.put(block) | |
} | |
await carWriter.close() | |
// wait for car to be written to fs | |
await carWritten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice! thanks!
License: MIT Signed-off-by: Oli Evans <[email protected]>
License: MIT Signed-off-by: Oli Evans <[email protected]>
@@ -80,7 +77,6 @@ export function extract (blockstore, path) { | |||
* @returns {AsyncIterable<Block>} | |||
*/ | |||
async function * exportBlocks (blockstore, block) { | |||
yield block |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to yield the block before the recursive call to exportBlocks
if not yielding from within.
Upgrade this lib so we can use it for extracting paths all over the place (dagula, freeway, etc)
@web3-strorage/ipfs-path
and the cli is nowipfs-path
extract
the default cli command so it works without passing it as an arg.License: MIT