This repository was archived by the owner on Feb 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add wrapWithDirectory flag to files.add et al #1290
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -148,7 +148,8 @@ exports.add = { | |
then: Joi.boolean().valid(false).required(), | ||
otherwise: Joi.boolean().valid(false) | ||
}), | ||
'only-hash': Joi.boolean() | ||
'only-hash': Joi.boolean(), | ||
'wrap-with-directory': Joi.boolean() | ||
}) | ||
// TODO: Necessary until validate "recursive", "stream-channels" etc. | ||
.options({ allowUnknown: true }) | ||
|
@@ -208,7 +209,8 @@ exports.add = { | |
rawLeaves: request.query['raw-leaves'], | ||
progress: request.query.progress ? progressHandler : null, | ||
onlyHash: request.query['only-hash'], | ||
hashAlg: request.query['hash'] | ||
hashAlg: request.query['hash'], | ||
wrapWithDirectory: request.query['wrap-with-directory'] | ||
} | ||
|
||
const aborter = abortable() | ||
|
@@ -246,7 +248,7 @@ exports.add = { | |
ipfs.files.addPullStream(options), | ||
pull.map((file) => { | ||
return { | ||
Name: file.path ? file.path : file.hash, | ||
Name: file.path, //addPullStream already turned this into a hash if it wanted to | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was already being done in addPullStream so I removed it from here, because addPullStream has a new case where it is leaving path as an empty string and wants it that way. |
||
Hash: file.hash, | ||
Size: file.size | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 admittedly don't know 100% of what's going on here or why the go implementation behaves this way but having it return an empty path for the wrapper directory feels like an anti-pattern.
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 was explained as "the wrapper is the root"