-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Outputs added directories as they are traversed. #2531
Conversation
(I still have some tests to fix up, now that the add order has changed.) |
No. The change to output directories at the end of the add was a conscious decision, files in a directory may be added before or after the directory itself is 'added' so the hash of the directory may change. No order is guaranteed about the stream of objects being added in an add |
Ah, this makes sense now. Consider a case like:
We need to create the However, this doesn't mean we must output them at the end: we can still perform a formatting step post-add that will provide a more traditional output structure (subfiles THEN containing dir). |
edeca42
to
bace3ec
Compare
I ended up modifying the existing logic to use MFS for traversal instead of relying on the dag service directly. I had to tweak how |
96fc1d1
to
312aef9
Compare
child, err := root.Links[0].GetNode(adder.ctx, adder.node.DAG) | ||
name = rootNode.Links[0].Name | ||
|
||
root, err = adder.mr.GetValue().(*mfs.Directory).Child(name) |
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.
we'll want to do some type checking here:
dir, ok := adder.mr.GetValue().(*mfs.Directory)
if !ok {
// errrorrrr
}
root, err = dir.Child(name)
...
9cf1808
to
6c7430b
Compare
6c7430b
to
9e616b1
Compare
🎉 Ready for merge! |
@@ -200,21 +207,35 @@ func (adder *Adder) Finalize() (*dag.Node, error) { | |||
return nil, err | |||
} | |||
|
|||
return root, nil | |||
rootNode, err = root.GetNode() |
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.
can actually just do return root.GetNode()
its a little cleaner looking
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.
Agreed -- changed.
License: MIT Signed-off-by: Stephen Whitmore <[email protected]>
License: MIT Signed-off-by: Stephen Whitmore <[email protected]>
License: MIT Signed-off-by: Stephen Whitmore <[email protected]>
License: MIT Signed-off-by: Stephen Whitmore <[email protected]>
License: MIT Signed-off-by: Stephen Whitmore <[email protected]>
License: MIT Signed-off-by: Stephen Whitmore <[email protected]>
License: MIT Signed-off-by: Stephen Whitmore <[email protected]>
This reverts commit dfd98f2. License: MIT Signed-off-by: Stephen Whitmore <[email protected]>
9e616b1
to
7e88f83
Compare
License: MIT Signed-off-by: Stephen Whitmore <[email protected]>
Anything else you need done in here, @whyrusleeping? |
Nope, this LGTM |
This also fixes a bug where adding with -n would prevent directories from
being outputted. Addresses #2530.
Bonus: directories no longer appear at the end of the list for
ipfs add
--they're in order! 👯