-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: use unixfs exporter to traverse DAGs #455
Conversation
Reuse the existing exporter `walkPath` method to traverse a DAG as it is clever enough to not load unecessary blocks which is important when traversing HAMTs.
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.
Lgtm. I knew it should have been easier than Adin and I were making it out to be
// should be able to cat the index file without loading the other files | ||
// in the shard - the blockstore is offline so will throw if requested | ||
// blocks are not present | ||
const bytes = await toBuffer(fs.cat(dir.cid, { |
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.
I see. Nice 👍
const p = `/ipfs/${cid}${path == null ? '' : `/${path}`}` | ||
const segments = await all(walkPath(p, blockstore, options)) | ||
|
||
if (segments.length === 0) { | ||
throw new DoesNotExistError('Could not find path in directory') | ||
} |
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 so much cleaner.
Reuse the existing exporter
walkPath
method to traverse a DAG as it is clever enough to not load unnecessary blocks which is important when traversing HAMTs.Change checklist