Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

feat: use latest IPFS, tests pass, avoid using internals #23

Merged
merged 3 commits into from
Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@
},
"homepage": "https://github.com/ipfs/js-ipfs-mfs#readme",
"devDependencies": {
"aegir": "^17.0.0",
"aegir": "^17.0.1",
"chai": "^4.2.0",
"detect-node": "^2.0.4",
"detect-webworker": "^1.0.0",
"dirty-chai": "^2.0.1",
"ipfs": "~0.32.3",
"ipfs": "~0.33.0",
"pull-buffer-stream": "^1.0.0",
"tmp": "~0.0.33"
},
"dependencies": {
"async": "^2.6.1",
"blob": "~0.0.4",
"blob": "~0.0.5",
"cids": "~0.5.5",
"debug": "^4.1.0",
"file-api": "~0.10.4",
Expand All @@ -58,7 +58,7 @@
"ipfs-unixfs-engine": "~0.33.0",
"is-pull-stream": "~0.0.0",
"is-stream": "^1.1.0",
"joi": "^14.0.1",
"joi": "^14.0.4",
"joi-browser": "^13.4.0",
"mortice": "^1.2.1",
"once": "^1.4.0",
Expand Down
4 changes: 2 additions & 2 deletions src/core/utils/traverse-to.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ const traverseToMfsObject = (ipfs, path, options, callback) => {
parent: null
})

reduce(pathSegments.map((pathSegment, index) => ({pathSegment, index})), {
reduce(pathSegments.map((pathSegment, index) => ({ pathSegment, index })), {
name: FILE_SEPARATOR,
node: rootNode,
parent: null
}, (parent, {pathSegment, index}, done) => {
}, (parent, { pathSegment, index }, done) => {
const existingLink = parent.node.links.find(link => link.name === pathSegment)

if (!existingLink) {
Expand Down
4 changes: 2 additions & 2 deletions src/core/utils/with-mfs-root.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@ const withMfsRoot = (ipfs, callback) => {

return waterfall([
// Store an empty node as the root
(next) => ipfs.files.add({
(next) => ipfs.add({
path: '/'
}, next),
// Turn the hash into a Buffer
([{hash}], next) => next(null, new CID(hash)),
([{ hash }], next) => next(null, new CID(hash)),
(cid, next) => repo.closed ? datastore.open((error) => next(error, cid)) : next(null, cid),
// Store the Buffer in the datastore
(cid, next) => datastore.put(MFS_ROOT_KEY, cid.buffer, (error) => next(error, cid))
Expand Down
20 changes: 10 additions & 10 deletions test/write.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ describe('write', function () {
})
})

runTest(({type, path, content}) => {
runTest(({ type, path, content }) => {
it(`limits how many bytes to write to a file (${type})`, () => {
return mfs.write(path, content, {
create: true,
Expand All @@ -276,7 +276,7 @@ describe('write', function () {
})
})

runTest(({type, path, content, contentSize}) => {
runTest(({ type, path, content, contentSize }) => {
it(`overwrites start of a file without truncating (${type})`, () => {
const newContent = Buffer.from('Goodbye world')

Expand All @@ -294,7 +294,7 @@ describe('write', function () {
})
})

runTest(({type, path, content, contentSize}) => {
runTest(({ type, path, content, contentSize }) => {
it(`pads the start of a new file when an offset is specified (${type})`, () => {
const offset = 10

Expand All @@ -316,7 +316,7 @@ describe('write', function () {
})
})

runTest(({type, path, content, contentSize}) => {
runTest(({ type, path, content, contentSize }) => {
it(`expands a file when an offset is specified (${type})`, () => {
const offset = contentSize - 1
const newContent = Buffer.from('Oh hai!')
Expand All @@ -336,7 +336,7 @@ describe('write', function () {
})
})

runTest(({type, path, content, contentSize}) => {
runTest(({ type, path, content, contentSize }) => {
it(`expands a file when an offset is specified and the offset is longer than the file (${type})`, () => {
const offset = contentSize + 5
const newContent = Buffer.from('Oh hai!')
Expand All @@ -358,7 +358,7 @@ describe('write', function () {
})
})

runTest(({type, path, content}) => {
runTest(({ type, path, content }) => {
it(`truncates a file after writing (${type})`, () => {
const newContent = Buffer.from('Oh hai!')

Expand All @@ -375,7 +375,7 @@ describe('write', function () {
})
})

runTest(({type, path, content}) => {
runTest(({ type, path, content }) => {
it(`truncates a file after writing with a stream (${type})`, () => {
const newContent = Buffer.from('Oh hai!')
const stream = values([newContent])
Expand All @@ -393,7 +393,7 @@ describe('write', function () {
})
})

runTest(({type, path, content}) => {
runTest(({ type, path, content }) => {
it(`truncates a file after writing with a stream with an offset (${type})`, () => {
const offset = 100
const newContent = Buffer.from('Oh hai!')
Expand All @@ -411,7 +411,7 @@ describe('write', function () {
})
})

runTest(({type, path, content}) => {
runTest(({ type, path, content }) => {
it(`writes a file with raw blocks for newly created leaf nodes (${type})`, () => {
return mfs.write(path, content, {
create: true,
Expand Down Expand Up @@ -439,7 +439,7 @@ describe('write', function () {
}

return Promise.all(
files.map(({name, source}) => mfs.write(`/concurrent/${name}`, source, {
files.map(({ name, source }) => mfs.write(`/concurrent/${name}`, source, {
create: true,
parents: true
}))
Expand Down