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

Commit

Permalink
Merge branch 'master' into feat/pubsub
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jan 11, 2017
2 parents 3082c2f + 6a5afdd commit d647803
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 17 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ Every IPFS instance also exposes the libp2p API at `ipfs.libp2p`. The formal int
```sh
# run all the interop tsts
> npm test:interop
> npm run test:interop

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

# run just IPFS benchmarks in Node.js
> npm run test:benchmark:node
Expand Down
6 changes: 3 additions & 3 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,11 +218,11 @@ UPDATE:

- Import and Export files just like go-ipfs
- unixfs-engine support of:
- [ ] trickle-dag
- [ ] balanced-dag-
- [x] trickle-dag
- [x] balanced-dag-
- [ ] sharding (HAMT)
- ensure compatibility with go
- [ ] import export files both implementations (tests)
- [x] import export files both implementations (tests)
- [ ] exchange files (bitswap) betweeen both implementations (tests)
- Files API (mfs)
- [ ] Complete the spec https://github.com/ipfs/interface-ipfs-core/pull/38
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ipfs",
"version": "0.20.3",
"version": "0.20.4",
"description": "JavaScript implementation of the IPFS specification",
"bin": {
"jsipfs": "src/cli/bin.js"
Expand Down Expand Up @@ -93,14 +93,14 @@
"hapi-set-header": "^1.0.2",
"hoek": "^4.1.0",
"idb-pull-blob-store": "^0.5.1",
"ipfs-api": "^12.1.3",
"ipfs-api": "^12.1.4",
"ipfs-bitswap": "^0.9.0",
"ipfs-block": "^0.5.4",
"ipfs-block-service": "^0.8.0",
"ipfs-multipart": "^0.1.0",
"ipfs-repo": "^0.11.2",
"ipfs-unixfs": "^0.1.9",
"ipfs-unixfs-engine": "^0.14.2",
"ipfs-unixfs-engine": "^0.15.0",
"ipld-resolver": "^0.4.1",
"isstream": "^0.1.2",
"libp2p-floodsub": "0.7.1",
Expand Down Expand Up @@ -157,6 +157,7 @@
"Stephen Whitmore <stephen.whitmore@gmail.com>",
"Stephen Whitmore <noffle@users.noreply.github.com>",
"Victor Bjelkholm <victorbjelkholm@gmail.com>",
"Xiao Liang <yxliang01@users.noreply.github.com>",
"greenkeeperio-bot <support@greenkeeper.io>",
"haad <haad@headbanggames.com>",
"jbenet <juan@benet.ai>",
Expand Down
13 changes: 11 additions & 2 deletions src/cli/commands/files/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,21 @@ module.exports = {
alias: 'r',
type: 'boolean',
default: false
},
trickle: {
alias: 't',
type: 'boolean',
default: false,
describe: 'Use the trickle DAG builder'
}
},

handler (argv) {
const inPath = checkPath(argv.file, argv.recursive)
const index = inPath.lastIndexOf('/') + 1
const options = {
strategy: argv.trickle ? 'trickle' : 'balanced'
}

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

// TODO: revist when interface-ipfs-core exposes pull-streams
let createAddStream = (cb) => {
ipfs.files.createAddStream((err, stream) => {
ipfs.files.createAddStream(options, (err, stream) => {
cb(err, err ? null : toPull.transform(stream))
})
}

if (typeof ipfs.files.createAddPullStream === 'function') {
createAddStream = (cb) => {
cb(null, ipfs.files.createAddPullStream())
cb(null, ipfs.files.createAddPullStream(options))
}
}

Expand Down
21 changes: 14 additions & 7 deletions src/core/components/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,37 @@ const CID = require('cids')
const waterfall = require('async/waterfall')

module.exports = function files (self) {
const createAddPullStream = () => {
const createAddPullStream = (options) => {
return pull(
pull.map(normalizeContent),
pull.flatten(),
importer(self._ipldResolver),
importer(self._ipldResolver, options),
pull.asyncMap(prepareFile.bind(null, self))
)
}

return {
createAddStream: (callback) => {
callback(null, toStream(createAddPullStream()))
createAddStream: (options, callback) => {
if (typeof options === 'function') {
callback = options
options = undefined
}
callback(null, toStream(createAddPullStream(options)))
},

createAddPullStream: createAddPullStream,

add: promisify((data, callback) => {
if (!callback || typeof callback !== 'function') {
add: promisify((data, options, callback) => {
if (typeof options === 'function') {
callback = options
options = undefined
} else if (!callback || typeof callback !== 'function') {
callback = noop
}

pull(
pull.values(normalizeContent(data)),
importer(self._ipldResolver),
importer(self._ipldResolver, options),
pull.asyncMap(prepareFile.bind(null, self)),
sort((a, b) => {
if (a.path < b.path) return 1
Expand Down

0 comments on commit d647803

Please sign in to comment.