diff --git a/SPEC/FILES.md b/SPEC/FILES.md index 419cb6dcc..d85cc86cb 100644 --- a/SPEC/FILES.md +++ b/SPEC/FILES.md @@ -1204,22 +1204,22 @@ await ipfs.files.mv('/src-file1', '/src-file2', '/dst-dir') > Flush a given path's data to the disk -##### `ipfs.files.flush([...paths])` +##### `ipfs.files.flush([path])` Where: -- `paths` are optional string paths to flush (default: `/`) +- `path` is an optional string path to flush (default: `/`) **Returns** | Type | Description | | -------- | -------- | -| `Promise` | If successfully copied. Otherwise an error will be thrown | +| `Promise` | The CID of the path that has been flushed | **Example:** ```JavaScript -await ipfs.files.flush('/') +const cid = await ipfs.files.flush('/') ``` #### `files.ls` diff --git a/src/files-mfs/flush.js b/src/files-mfs/flush.js index 54c74cdcf..d7d282d18 100644 --- a/src/files-mfs/flush.js +++ b/src/files-mfs/flush.js @@ -32,13 +32,22 @@ module.exports = (common, options) => { } }) - it('should flush root', () => ipfs.files.flush()) + it('should flush root', async () => { + const root = await ipfs.files.stat('/') + const flushed = await ipfs.files.flush() + + expect(root.hash).to.equal(flushed.toString()) + }) it('should flush specific dir', async () => { const testDir = `/test-${hat()}` await ipfs.files.mkdir(testDir, { parents: true }) - await ipfs.files.flush(testDir) + + const dirStats = await ipfs.files.stat(testDir) + const flushed = await ipfs.files.flush(testDir) + + expect(dirStats.hash).to.equal(flushed.toString()) }) }) }