Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Commit e29e665

Browse files
committed
feat: support --raw-leaves
1 parent 48aceb1 commit e29e665

File tree

3 files changed

+7
-46
lines changed

3 files changed

+7
-46
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@
108108
"ipfs-block": "~0.7.1",
109109
"ipfs-block-service": "~0.14.0",
110110
"ipfs-http-response": "~0.1.2",
111-
"ipfs-mfs": "~0.1.0",
111+
"ipfs-mfs": "~0.2.1",
112112
"ipfs-multipart": "~0.1.0",
113113
"ipfs-repo": "~0.22.1",
114114
"ipfs-unixfs": "~0.1.15",
115-
"ipfs-unixfs-engine": "~0.30.0",
115+
"ipfs-unixfs-engine": "~0.31.1",
116116
"ipld": "~0.17.3",
117117
"ipld-dag-cbor": "~0.12.1",
118118
"ipld-dag-pb": "~0.14.5",

src/cli/commands/files/add.js

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,13 @@ module.exports = {
145145
},
146146
'raw-leaves': {
147147
type: 'boolean',
148-
default: undefined,
148+
default: false,
149149
describe: 'Use raw blocks for leaf nodes. (experimental)'
150150
},
151151
'cid-version': {
152152
type: 'integer',
153-
describe: 'Cid version. Non-zero value will change default of \'raw-leaves\' to true. (experimental)'
153+
describe: 'CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental)',
154+
default: 0
154155
},
155156
hash: {
156157
type: 'string',
@@ -197,34 +198,6 @@ module.exports = {
197198
pin: argv.pin
198199
}
199200

200-
// Temporary restriction on raw-leaves:
201-
// When cid-version=1 then raw-leaves MUST be present and false.
202-
//
203-
// This is because raw-leaves is not yet implemented in js-ipfs,
204-
// and go-ipfs changes the value of raw-leaves to true when
205-
// cid-version > 0 unless explicitly set to false.
206-
//
207-
// This retains feature parity without having to implement raw-leaves.
208-
if (options.cidVersion > 0 && options.rawLeaves !== false) {
209-
throw new Error('Implied argument raw-leaves must be passed and set to false when cid-version is > 0')
210-
}
211-
212-
// Temporary restriction on raw-leaves:
213-
// When hash != undefined then raw-leaves MUST be present and false.
214-
//
215-
// This is because raw-leaves is not yet implemented in js-ipfs,
216-
// and go-ipfs changes the value of raw-leaves to true when
217-
// hash != undefined unless explicitly set to false.
218-
//
219-
// This retains feature parity without having to implement raw-leaves.
220-
if (options.hash && options.rawLeaves !== false) {
221-
throw new Error('Implied argument raw-leaves must be passed and set to false when hash argument is specified')
222-
}
223-
224-
if (options.rawLeaves) {
225-
throw new Error('Not implemented: raw-leaves')
226-
}
227-
228201
if (options.enableShardingExperiment && utils.isDaemonOn()) {
229202
throw new Error('Error: Enabling the sharding experiment should be done on the daemon')
230203
}

src/http/api/resources/files.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -153,20 +153,8 @@ exports.add = {
153153
validate: {
154154
query: Joi.object()
155155
.keys({
156-
'cid-version': Joi.number().integer().min(0).max(1),
157-
// Temporary restriction on raw-leaves:
158-
// When cid-version=1 then raw-leaves MUST be present and false.
159-
//
160-
// This is because raw-leaves is not yet implemented in js-ipfs,
161-
// and go-ipfs changes the value of raw-leaves to true when
162-
// cid-version > 0 unless explicitly set to false.
163-
//
164-
// This retains feature parity without having to implement raw-leaves.
165-
'raw-leaves': Joi.boolean().when('cid-version', {
166-
is: 1,
167-
then: Joi.boolean().valid(false).required(),
168-
otherwise: Joi.boolean().valid(false)
169-
}),
156+
'cid-version': Joi.number().integer().min(0).max(1).default(0),
157+
'raw-leaves': Joi.boolean(),
170158
'only-hash': Joi.boolean(),
171159
pin: Joi.boolean().default(true),
172160
'wrap-with-directory': Joi.boolean()

0 commit comments

Comments
 (0)