Skip to content
This repository has been archived by the owner on Aug 12, 2020. It is now read-only.

exporter: Support slicing streams stored in deeply nested DAGs #208

Merged
merged 1 commit into from
Mar 27, 2018

Conversation

achingbrain
Copy link
Collaborator

The previous attempt at this didn't handle larger files where the tree can have multiple tiers of DAGNodes - this PR builds on the existing exporter tree traversal to export slices of streams instead of the whole file (the slice could be the same size of the file of course).

The approach is:

  1. Load the DAGNode corresponding to the passed hash (e.g. the root)
  2. If begin and end are passed, sanitise & respect them, otherwise use 0 and the filesize reported by the root DAGNode to export the whole file
  3. Use the blockSizes attribute of the DAGNode to work out which DAGLinks we should follow to only retrieve the requested byte range
  4. Descend into the graph depth first, emitting any file data found. Where further DAGLinks are encountered, again use the blockSizes attribute to only traverse to the requested data.

@ghost ghost assigned achingbrain Mar 27, 2018
@ghost ghost added the status/in-progress In progress label Mar 27, 2018
@@ -75,6 +74,7 @@
"pull-pause": "0.0.2",
"pull-pushable": "^2.2.0",
"pull-stream": "^3.6.2",
"pull-through": "^1.0.18",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR doesn't actually use pull-through - it appears to be a missing dependency as it's used by the builder and trickle-reducer modules.

test/exporter.js Outdated
console.info(err)

console.info(data.length)
console.info(expected.length)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra console logs for testing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed them

@achingbrain achingbrain force-pushed the slice-nested-streams branch from bf62319 to 6e6e39f Compare March 27, 2018 14:33
@daviddias daviddias merged commit 8568cd5 into ipfs-inactive:master Mar 27, 2018
@ghost ghost removed the status/in-progress In progress label Mar 27, 2018
@achingbrain achingbrain deleted the slice-nested-streams branch March 27, 2018 15:38
achingbrain added a commit that referenced this pull request May 26, 2018
Part of making the hases emitted by js-ipfs the same as go-ipfs meant unsetting
the data attribute of UnixFS metadata objects if the data buffer had 0 length.

ipfs.files.get converts a pull stream of files into a readable stream of files
and all of the content pull streams too. If an empty buffer is not emitted by
the file content pull stream for file with no data then no file is written
out to the filesystem.

This was a fun bug to track down.

This module used to emit empty buffers for UnixFS metadata with no data
property but I removed it as part of #208 as there was no test that failed
without it so here we reinstate it and add a test.
achingbrain added a commit that referenced this pull request Jun 8, 2018
Part of making the hases emitted by js-ipfs the same as go-ipfs meant unsetting
the data attribute of UnixFS metadata objects if the data buffer had 0 length.

ipfs.files.get converts a pull stream of files into a readable stream of files
and all of the content pull streams too. If an empty buffer is not emitted by
the file content pull stream for file with no data then no file is written
out to the filesystem.

This was a fun bug to track down.

This module used to emit empty buffers for UnixFS metadata with no data
property but I removed it as part of #208 as there was no test that failed
without it so here we reinstate it and add a test.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants