This repository has been archived by the owner on Aug 12, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* option for only-hash * Adds tests for only-hash option --only-hash will chunk and hash input - but not write it to disk * removes console.logging * restores src/importer/flush-tree (which is not actually ever used or executed) * Removes .only on a test and changes the option name. Adds reference to 'onlyHash' in the read me * Fix the tests
- Loading branch information
Showing
14 changed files
with
124 additions
and
24 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
|
@@ -81,6 +81,7 @@ | |
}, | ||
"contributors": [ | ||
"Alan Shaw <[email protected]>", | ||
"Bernard Mordan <[email protected]>", | ||
"David Dias <[email protected]>", | ||
"Francisco Baio Dias <[email protected]>", | ||
"Friedel Ziegelmayer <[email protected]>", | ||
|
This file contains 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 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 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 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 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 |
---|---|---|
@@ -1,4 +1,8 @@ | ||
'use strict' | ||
|
||
module.exports = class Dir { | ||
constructor (props, _options) { | ||
this._options = _options || {} | ||
Object.assign(this, props) | ||
} | ||
} |
This file contains 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 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* eslint-env mocha */ | ||
'use strict' | ||
|
||
const chai = require('chai') | ||
chai.use(require('dirty-chai')) | ||
const expect = chai.expect | ||
const BlockService = require('ipfs-block-service') | ||
const pull = require('pull-stream') | ||
const IPLDResolver = require('ipld-resolver') | ||
const CID = require('cids') | ||
const createBuilder = require('../src/builder') | ||
const FixedSizeChunker = require('../src/chunker/fixed-size') | ||
|
||
module.exports = (repo) => { | ||
describe('builder', () => { | ||
let ipldResolver | ||
|
||
before(() => { | ||
const bs = new BlockService(repo) | ||
ipldResolver = new IPLDResolver(bs) | ||
}) | ||
|
||
it('will only chunk and hash if passed an "onlyHash" option', (done) => { | ||
const onCollected = (err, nodes) => { | ||
if (err) return done(err) | ||
|
||
const node = nodes[0] | ||
expect(node).to.exist() | ||
|
||
ipldResolver.get(new CID(node.multihash), (err, res) => { | ||
expect(err).to.exist() | ||
done() | ||
}) | ||
} | ||
|
||
const content = String(Math.random() + Date.now()) | ||
const inputFile = { | ||
path: content + '.txt', | ||
content: Buffer.from(content) | ||
} | ||
|
||
const options = { | ||
onlyHash: true | ||
} | ||
|
||
pull( | ||
pull.values([inputFile]), | ||
createBuilder(FixedSizeChunker, ipldResolver, options), | ||
pull.collect(onCollected) | ||
) | ||
}) | ||
}) | ||
} |
This file contains 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