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

Commit

Permalink
Revert "feat: complete files.stat with the 'with-local' option (#227)"
Browse files Browse the repository at this point in the history
This reverts commit 5969fed.
  • Loading branch information
vmx committed Mar 13, 2018
1 parent ec16016 commit de72184
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 89 deletions.
5 changes: 0 additions & 5 deletions SPEC/FILES.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,6 @@ Where:
- `options` is an optional Object that might contain the following keys:
- `hash` is a Boolean value to return only the hash.
- `size` is a Boolean value to return only the size.
- `withLocal` is a Boolean value to compute the amount of the dag that is local, and if possible the total size.

`callback` must follow the `function (err, stat) {}` signature, where `err` is an Error if the operation was not successful and `stat` is an Object with the following keys:

Expand All @@ -627,10 +626,6 @@ Where:
- `cumulativeSize` is an integer with the cumulative size in Bytes.
- `blocks` is an integer indicating the number of blocks.
- `type` is a string that can be either `directory` or `file`.
- `withLocality` is a boolean to indicate if locality information are present.
- `local` is a boolean to indicate if the queried dag is fully present locally.
- `sizeLocal` is an integer indicating the cumulative size of the data present locally.


If no `callback` is passed, a promise is returned.

Expand Down
54 changes: 2 additions & 52 deletions js/src/files-mfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,7 @@ module.exports = (common) => {
blocks: 1,
size: 13,
hash: 'QmcZojhwragQr5qhTeFAmELik623Z21e3jBTpJXoQ9si1T',
cumulativeSize: 71,
withLocality: false,
local: undefined,
sizeLocal: undefined
cumulativeSize: 71
})
done()
})
Expand All @@ -298,54 +295,7 @@ module.exports = (common) => {
blocks: 2,
size: 0,
hash: 'QmVrkkNurBCeJvPRohW5JTvJG4AxGrFg7FnmsZZUS6nJto',
cumulativeSize: 216,
withLocality: false,
local: undefined,
sizeLocal: undefined
})
done()
})
})

it('stat withLocal file', function (done) {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
this.skip()
}

ipfs.files.stat('/test/b', {'withLocal': true}, (err, stat) => {
expect(err).to.not.exist()
expect(stat).to.eql({
type: 'file',
blocks: 1,
size: 13,
hash: 'QmcZojhwragQr5qhTeFAmELik623Z21e3jBTpJXoQ9si1T',
cumulativeSize: 71,
withLocality: true,
local: true,
sizeLocal: 71
})
done()
})
})

it('stat withLocal dir', function (done) {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
this.skip()
}

ipfs.files.stat('/test', {'withLocal': true}, (err, stat) => {
expect(err).to.not.exist()
expect(stat).to.eql({
type: 'directory',
blocks: 2,
size: 0,
hash: 'QmVrkkNurBCeJvPRohW5JTvJG4AxGrFg7FnmsZZUS6nJto',
cumulativeSize: 216,
withLocality: true,
local: true,
sizeLocal: 216
cumulativeSize: 216
})
done()
})
Expand Down
33 changes: 1 addition & 32 deletions js/src/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ module.exports = (common) => {
this.timeout(40 * 1000)

let ipfs
let withGo

function fixture (path) {
return loadFixture(path, 'interface-ipfs-core')
Expand Down Expand Up @@ -61,11 +60,7 @@ module.exports = (common) => {
factory.spawnNode((err, node) => {
expect(err).to.not.exist()
ipfs = node
node.id((err, id) => {
expect(err).to.not.exist()
withGo = id.agentVersion.startsWith('go-ipfs')
done()
})
done()
})
})
})
Expand Down Expand Up @@ -1007,31 +1002,5 @@ module.exports = (common) => {
)
})
})

describe('.stat', () => {
before((done) => ipfs.files.add(smallFile.data, done))

it('stat outside of mfs', function (done) {
if (!withGo) {
console.log('Not supported in js-ipfs yet')
this.skip()
}

ipfs.files.stat('/ipfs/' + smallFile.cid, (err, stat) => {
expect(err).to.not.exist()
expect(stat).to.eql({
type: 'file',
blocks: 0,
size: 12,
hash: 'Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP',
cumulativeSize: 20,
withLocality: false,
local: undefined,
sizeLocal: undefined
})
done()
})
})
})
})
}

0 comments on commit de72184

Please sign in to comment.