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

Commit 5034215

Browse files
authored
docs: update files.flush return type (#579)
* docs: update files.flush return type `ipfs.files.flush` returns the CID of the flushed path since `go-IPFS@v0.4.20`. It also only takes one path as an optional parameter. * test: update tests to assert CIDs are returned * fix: linting
1 parent 8852f94 commit 5034215

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

SPEC/FILES.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,22 +1204,22 @@ await ipfs.files.mv('/src-file1', '/src-file2', '/dst-dir')
12041204

12051205
> Flush a given path's data to the disk
12061206
1207-
##### `ipfs.files.flush([...paths])`
1207+
##### `ipfs.files.flush([path])`
12081208

12091209
Where:
12101210

1211-
- `paths` are optional string paths to flush (default: `/`)
1211+
- `path` is an optional string path to flush (default: `/`)
12121212

12131213
**Returns**
12141214

12151215
| Type | Description |
12161216
| -------- | -------- |
1217-
| `Promise<void>` | If successfully copied. Otherwise an error will be thrown |
1217+
| `Promise<CID>` | The CID of the path that has been flushed |
12181218

12191219
**Example:**
12201220

12211221
```JavaScript
1222-
await ipfs.files.flush('/')
1222+
const cid = await ipfs.files.flush('/')
12231223
```
12241224

12251225
#### `files.ls`

src/files-mfs/flush.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,22 @@ module.exports = (common, options) => {
3232
}
3333
})
3434

35-
it('should flush root', () => ipfs.files.flush())
35+
it('should flush root', async () => {
36+
const root = await ipfs.files.stat('/')
37+
const flushed = await ipfs.files.flush()
38+
39+
expect(root.hash).to.equal(flushed.toString())
40+
})
3641

3742
it('should flush specific dir', async () => {
3843
const testDir = `/test-${hat()}`
3944

4045
await ipfs.files.mkdir(testDir, { parents: true })
41-
await ipfs.files.flush(testDir)
46+
47+
const dirStats = await ipfs.files.stat(testDir)
48+
const flushed = await ipfs.files.flush(testDir)
49+
50+
expect(dirStats.hash).to.equal(flushed.toString())
4251
})
4352
})
4453
}

0 commit comments

Comments
 (0)