From 3742e98e35c8023eba20b9a92d9a4db3bc62a673 Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 3 Apr 2018 16:56:15 +0100 Subject: [PATCH] feat: garbage collector button on settings (#636) --- package.json | 10 +++++----- src/controls/main/gc.js | 15 +++++++++++++++ src/controls/main/index.js | 2 ++ src/panes/Settings.js | 10 ++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 src/controls/main/gc.js diff --git a/package.json b/package.json index 5bb4c50bc..0224ca706 100644 --- a/package.json +++ b/package.json @@ -18,15 +18,15 @@ "ipfsd-ctl": "^0.31.0", "is-ipfs": "^0.3.2", "lodash.clonedeep": "^4.5.0", - "moment": "^2.21.0", + "moment": "^2.22.0", "multiaddr": "^3.1.0", "normalize.css": "^8.0.0", "pretty-bytes": "^4.0.2", "prop-types": "^15.6.1", - "react": "^16.2.0", + "react": "^16.3.0", "react-dnd": "^2.6.0", "react-dnd-html5-backend": "^2.6.0", - "react-dom": "^16.2.0" + "react-dom": "^16.3.0" }, "devDependencies": { "babel-eslint": "^8.2.2", @@ -49,11 +49,11 @@ "eslint-plugin-react": "^7", "expect": "^23.0.0-alpha.0", "istanbul": "^0.4.5", - "jsdom": "^11.6.2", + "jsdom": "^11.7.0", "mocha": "^5.0.5", "nyc": "^11.6.0", "pre-commit": "^1.2.2", - "sinon": "^4.4.9", + "sinon": "^4.5.0", "spectron": "^3.8.0" }, "scripts": { diff --git a/src/controls/main/gc.js b/src/controls/main/gc.js new file mode 100644 index 000000000..e79c02655 --- /dev/null +++ b/src/controls/main/gc.js @@ -0,0 +1,15 @@ +import {ipcMain} from 'electron' + +function gc (opts) { + let {debug, ipfs} = opts + + return () => { + ipfs().repo.gc() + .then(() => { debug('Garbage collector run sucessfully') }) + .catch(e => { debug(e.stack) }) + } +} + +export default function (opts) { + ipcMain.on('run-gc', gc(opts)) +} diff --git a/src/controls/main/index.js b/src/controls/main/index.js index 8fb90243b..06522fa1f 100644 --- a/src/controls/main/index.js +++ b/src/controls/main/index.js @@ -1,6 +1,7 @@ import autoLaunch from './auto-launch' import downloadHash from './download-hash' import files from './files' +import gc from './gc' import menuShortcuts from './menu-shortcuts' import openFileDialog from './open-file-dialog' import openUrl from './open-url' @@ -15,6 +16,7 @@ export default function (opts) { autoLaunch(opts) downloadHash(opts) files(opts) + gc(opts) menuShortcuts(opts) openFileDialog(opts) openUrl(opts) diff --git a/src/panes/Settings.js b/src/panes/Settings.js index 7e60a3ec7..a41226e8a 100644 --- a/src/panes/Settings.js +++ b/src/panes/Settings.js @@ -14,6 +14,10 @@ function generateOnChange (key) { } } +function garbageCollector () { + ipcRenderer.send('run-gc') +} + function quit () { ipcRenderer.send('quit-application') } @@ -78,6 +82,12 @@ export default function Settings (props) {
{opts} + +