This repository has been archived by the owner on Mar 10, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
170 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
Repo API | ||
======= | ||
|
||
#### `gc` | ||
|
||
> Perform a garbage collection sweep on the repo. | ||
##### `Go` **WIP** | ||
|
||
##### `JavaScript` - ipfs.repo.gc([options, callback]) | ||
|
||
Where: | ||
|
||
- `options` is an object that contains following properties | ||
- `quiet` writes a minimal output. | ||
- `stream-errors` stream errors. | ||
|
||
`callback` must follow `function (err, res) {}` signature, where `err` is an Error if the operation was not successful. | ||
|
||
If no `callback` is passed, a promise is returned. | ||
|
||
**Example:** | ||
|
||
```JavaScript | ||
ipfs.repo.gc((err, res) => console.log(res)) | ||
``` | ||
|
||
#### `stat` | ||
|
||
> Get stats for the currently used repo. | ||
##### `Go` **WIP** | ||
|
||
##### `JavaScript` - ipfs.repo.stat([options, callback]) | ||
|
||
Where: | ||
|
||
- `options` is an object that contains following properties | ||
- `human` a Boolean value to output `repoSize` in MiB. | ||
|
||
`callback` must follow `function (err, stats) {}` signature, where `err` is an Error if the operation was not successful and `stats` is an object containing the following keys: | ||
|
||
- `numObjects` | ||
- `repoSize` | ||
- `repoPath` | ||
- `version` | ||
- `storageMax` | ||
|
||
If no `callback` is passed, a promise is returned. | ||
|
||
**Example:** | ||
|
||
```JavaScript | ||
ipfs.repo.stat((err, stats) => console.log(stats)) | ||
|
||
// { numObjects: 15, | ||
// repoSize: 64190, | ||
// repoPath: 'C:\\Users\\henri\\AppData\\Local\\Temp\\ipfs_687c6eb3da07d3b16fe3c63ce17560e9', | ||
// version: 'fs-repo@6', | ||
// storageMax: 10000000000 } | ||
``` | ||
|
||
#### `version` | ||
|
||
> Show the repo version. | ||
##### `Go` **WIP** | ||
|
||
##### `JavaScript` - ipfs.repo.version([callback]) | ||
|
||
`callback` must follow `function (err, version) {}` signature, where `err` is an Error if the operation was not successful and `version` is a String containing the version. | ||
|
||
If no `callback` is passed, a promise is returned. | ||
|
||
**Example:** | ||
|
||
```JavaScript | ||
ipfs.repo.version((err, version) => console.log(version)) | ||
|
||
// "6" | ||
``` |
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,86 @@ | ||
/* eslint-env mocha */ | ||
/* eslint max-nested-callbacks: ["error", 8] */ | ||
|
||
'use strict' | ||
|
||
const chai = require('chai') | ||
const dirtyChai = require('dirty-chai') | ||
const expect = chai.expect | ||
chai.use(dirtyChai) | ||
|
||
module.exports = (common) => { | ||
describe('.repo', () => { | ||
let ipfs | ||
|
||
before(function (done) { | ||
// CI takes longer to instantiate the daemon, so we need to increase the | ||
// timeout for the before step | ||
this.timeout(60 * 1000) | ||
|
||
common.setup((err, factory) => { | ||
expect(err).to.not.exist() | ||
factory.spawnNode((err, node) => { | ||
expect(err).to.not.exist() | ||
ipfs = node | ||
done() | ||
}) | ||
}) | ||
}) | ||
|
||
after((done) => { | ||
common.teardown(done) | ||
}) | ||
|
||
it('.version', (done) => { | ||
ipfs.repo.version((err, version) => { | ||
expect(err).to.not.exist() | ||
expect(version).to.exist() | ||
done() | ||
}) | ||
}) | ||
|
||
it('.version Promise', () => { | ||
return ipfs.repo.version().then((version) => { | ||
expect(version).to.exist() | ||
}) | ||
}) | ||
|
||
it('.stat', (done) => { | ||
ipfs.repo.stat((err, stat) => { | ||
expect(err).to.not.exist() | ||
expect(stat).to.exist() | ||
expect(stat).to.have.property('numObjects') | ||
expect(stat).to.have.property('repoSize') | ||
expect(stat).to.have.property('repoPath') | ||
expect(stat).to.have.property('version') | ||
expect(stat).to.have.property('storageMax') | ||
done() | ||
}) | ||
}) | ||
|
||
it('.stat Promise', () => { | ||
return ipfs.repo.stat().then((stat) => { | ||
expect(stat).to.exist() | ||
expect(stat).to.have.property('numObjects') | ||
expect(stat).to.have.property('repoSize') | ||
expect(stat).to.have.property('repoPath') | ||
expect(stat).to.have.property('version') | ||
expect(stat).to.have.property('storageMax') | ||
}) | ||
}) | ||
|
||
it('.gc', (done) => { | ||
ipfs.repo.gc((err, res) => { | ||
expect(err).to.not.exist() | ||
expect(res).to.exist() | ||
done() | ||
}) | ||
}) | ||
|
||
it('.gc Promise', () => { | ||
return ipfs.repo.gc().then((res) => { | ||
expect(res).to.exist() | ||
}) | ||
}) | ||
}) | ||
} |