Skip to content

Commit

Permalink
feat: garbage collector button on settings (#636)
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias authored Apr 3, 2018
1 parent 3d731fd commit 3742e98
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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": {
Expand Down
15 changes: 15 additions & 0 deletions src/controls/main/gc.js
Original file line number Diff line number Diff line change
@@ -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))
}
2 changes: 2 additions & 0 deletions src/controls/main/index.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -15,6 +16,7 @@ export default function (opts) {
autoLaunch(opts)
downloadHash(opts)
files(opts)
gc(opts)
menuShortcuts(opts)
openFileDialog(opts)
openUrl(opts)
Expand Down
10 changes: 10 additions & 0 deletions src/panes/Settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ function generateOnChange (key) {
}
}

function garbageCollector () {
ipcRenderer.send('run-gc')
}

function quit () {
ipcRenderer.send('quit-application')
}
Expand Down Expand Up @@ -78,6 +82,12 @@ export default function Settings (props) {
<div className='main'>
{opts}

<InfoBlock
title='Run garbage collector'
info='Delete all unpinned files to free up disk space.'
button={false}
onClick={garbageCollector} />

<InfoBlock
title='Quit'
button={false}
Expand Down

0 comments on commit 3742e98

Please sign in to comment.