diff --git a/README.md b/README.md index f7b51bd38..62bd692f4 100644 --- a/README.md +++ b/README.md @@ -169,6 +169,7 @@ $ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"P - [`ipfs.files.get(hash, [callback])`](https://github.com/ipfs/interface-ipfs-core/tree/master/SPEC/FILES.md#get) - alias to `ipfs.get` - `ipfs.ls` + - `ipfs.files.flush(path, [callback])` - mfs (mutable file system) specific: - `ipfs.files.cp` - `ipfs.files.ls` diff --git a/src/files/flush.js b/src/files/flush.js new file mode 100644 index 000000000..9f70f2adb --- /dev/null +++ b/src/files/flush.js @@ -0,0 +1,12 @@ +'use strict' + +const promisify = require('promisify-es6') + +module.exports = (send) => { + return promisify((args, callback) => { + return send({ + path: 'files/flush', + args: args + }, callback) + }) +} diff --git a/src/files/index.js b/src/files/index.js index 4b9796998..f729f4305 100644 --- a/src/files/index.js +++ b/src/files/index.js @@ -15,6 +15,7 @@ module.exports = (arg) => { get: require('./get')(send), getReadableStream: require('./get-readable-stream')(send), getPullStream: require('./get-pull-stream')(send), + flush: require('./flush')(send), // Specific to MFS (for now) cp: require('./cp')(send), diff --git a/test/files.spec.js b/test/files.spec.js index 3bfc4bf87..d16d471c6 100644 --- a/test/files.spec.js +++ b/test/files.spec.js @@ -200,6 +200,10 @@ describe('.files (the MFS API part)', function () { ipfs.files.mkdir('/test-folder', done) }) + it('files.flush', (done) => { + ipfs.files.flush('/', done) + }) + it('files.cp', (done) => { ipfs.files.cp([ '/ipfs/Qma4hjFTnCasJ8PVp3mZbZK5g2vGDT4LByLJ7m8ciyRFZP',