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

Commit d647803

Browse files
authored
Merge branch 'master' into feat/pubsub
2 parents 3082c2f + 6a5afdd commit d647803

File tree

5 files changed

+34
-17
lines changed

5 files changed

+34
-17
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ Every IPFS instance also exposes the libp2p API at `ipfs.libp2p`. The formal int
249249
250250
```sh
251251
# run all the interop tsts
252-
> npm test:interop
252+
> npm run test:interop
253253

254254
# run just IPFS interop tests in Node.js using one go-ipfs daemon and one js-ipfs daemon
255255
> npm run test:interop:node
@@ -262,7 +262,7 @@ Every IPFS instance also exposes the libp2p API at `ipfs.libp2p`. The formal int
262262
263263
```sh
264264
# run all the interop tsts
265-
> npm test:benchmark
265+
> npm run test:benchmark
266266

267267
# run just IPFS benchmarks in Node.js
268268
> npm run test:benchmark:node

ROADMAP.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ UPDATE:
218218

219219
- Import and Export files just like go-ipfs
220220
- unixfs-engine support of:
221-
- [ ] trickle-dag
222-
- [ ] balanced-dag-
221+
- [x] trickle-dag
222+
- [x] balanced-dag-
223223
- [ ] sharding (HAMT)
224224
- ensure compatibility with go
225-
- [ ] import export files both implementations (tests)
225+
- [x] import export files both implementations (tests)
226226
- [ ] exchange files (bitswap) betweeen both implementations (tests)
227227
- Files API (mfs)
228228
- [ ] Complete the spec https://github.com/ipfs/interface-ipfs-core/pull/38

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ipfs",
3-
"version": "0.20.3",
3+
"version": "0.20.4",
44
"description": "JavaScript implementation of the IPFS specification",
55
"bin": {
66
"jsipfs": "src/cli/bin.js"
@@ -93,14 +93,14 @@
9393
"hapi-set-header": "^1.0.2",
9494
"hoek": "^4.1.0",
9595
"idb-pull-blob-store": "^0.5.1",
96-
"ipfs-api": "^12.1.3",
96+
"ipfs-api": "^12.1.4",
9797
"ipfs-bitswap": "^0.9.0",
9898
"ipfs-block": "^0.5.4",
9999
"ipfs-block-service": "^0.8.0",
100100
"ipfs-multipart": "^0.1.0",
101101
"ipfs-repo": "^0.11.2",
102102
"ipfs-unixfs": "^0.1.9",
103-
"ipfs-unixfs-engine": "^0.14.2",
103+
"ipfs-unixfs-engine": "^0.15.0",
104104
"ipld-resolver": "^0.4.1",
105105
"isstream": "^0.1.2",
106106
"libp2p-floodsub": "0.7.1",
@@ -157,6 +157,7 @@
157157
"Stephen Whitmore <stephen.whitmore@gmail.com>",
158158
"Stephen Whitmore <noffle@users.noreply.github.com>",
159159
"Victor Bjelkholm <victorbjelkholm@gmail.com>",
160+
"Xiao Liang <yxliang01@users.noreply.github.com>",
160161
"greenkeeperio-bot <support@greenkeeper.io>",
161162
"haad <haad@headbanggames.com>",
162163
"jbenet <juan@benet.ai>",

src/cli/commands/files/add.js

+11-2
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,21 @@ module.exports = {
4747
alias: 'r',
4848
type: 'boolean',
4949
default: false
50+
},
51+
trickle: {
52+
alias: 't',
53+
type: 'boolean',
54+
default: false,
55+
describe: 'Use the trickle DAG builder'
5056
}
5157
},
5258

5359
handler (argv) {
5460
const inPath = checkPath(argv.file, argv.recursive)
5561
const index = inPath.lastIndexOf('/') + 1
62+
const options = {
63+
strategy: argv.trickle ? 'trickle' : 'balanced'
64+
}
5665

5766
utils.getIPFS((err, ipfs) => {
5867
if (err) {
@@ -61,14 +70,14 @@ module.exports = {
6170

6271
// TODO: revist when interface-ipfs-core exposes pull-streams
6372
let createAddStream = (cb) => {
64-
ipfs.files.createAddStream((err, stream) => {
73+
ipfs.files.createAddStream(options, (err, stream) => {
6574
cb(err, err ? null : toPull.transform(stream))
6675
})
6776
}
6877

6978
if (typeof ipfs.files.createAddPullStream === 'function') {
7079
createAddStream = (cb) => {
71-
cb(null, ipfs.files.createAddPullStream())
80+
cb(null, ipfs.files.createAddPullStream(options))
7281
}
7382
}
7483

src/core/components/files.js

+14-7
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,37 @@ const CID = require('cids')
1515
const waterfall = require('async/waterfall')
1616

1717
module.exports = function files (self) {
18-
const createAddPullStream = () => {
18+
const createAddPullStream = (options) => {
1919
return pull(
2020
pull.map(normalizeContent),
2121
pull.flatten(),
22-
importer(self._ipldResolver),
22+
importer(self._ipldResolver, options),
2323
pull.asyncMap(prepareFile.bind(null, self))
2424
)
2525
}
2626

2727
return {
28-
createAddStream: (callback) => {
29-
callback(null, toStream(createAddPullStream()))
28+
createAddStream: (options, callback) => {
29+
if (typeof options === 'function') {
30+
callback = options
31+
options = undefined
32+
}
33+
callback(null, toStream(createAddPullStream(options)))
3034
},
3135

3236
createAddPullStream: createAddPullStream,
3337

34-
add: promisify((data, callback) => {
35-
if (!callback || typeof callback !== 'function') {
38+
add: promisify((data, options, callback) => {
39+
if (typeof options === 'function') {
40+
callback = options
41+
options = undefined
42+
} else if (!callback || typeof callback !== 'function') {
3643
callback = noop
3744
}
3845

3946
pull(
4047
pull.values(normalizeContent(data)),
41-
importer(self._ipldResolver),
48+
importer(self._ipldResolver, options),
4249
pull.asyncMap(prepareFile.bind(null, self)),
4350
sort((a, b) => {
4451
if (a.path < b.path) return 1

0 commit comments

Comments
 (0)