Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix(repo): do not hang on calls to repo gc
Browse files Browse the repository at this point in the history
Previously calls to repo.gc would hang or fail silently or in the case of the HTTP API cause a 404. This PR responds to calls to repo.gc with an error to inform that this feature will eventually exist (it is spec'd) but is not implemented yet.

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
  • Loading branch information
alanshaw authored and daviddias committed Jun 4, 2018
1 parent 097edd5 commit 9fff46f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/cli/commands/repo/gc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
module.exports = {
command: 'gc',

describe: '',
describe: 'Perform a garbage collection sweep on the repo.',

builder: {},

handler (argv) {
argv.ipfs.repo.gc((err) => {
if (err) {
throw err
}
})
}
}
9 changes: 8 additions & 1 deletion src/core/components/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,14 @@ module.exports = function repo (self) {
})
}),

gc: () => {},
gc: promisify((options, callback) => {
if (typeof options === 'function') {
callback = options
options = {}
}

callback(new Error('Not implemented'))
}),

stat: promisify((options, callback) => {
if (typeof options === 'function') {
Expand Down
15 changes: 15 additions & 0 deletions src/http/api/resources/repo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

exports = module.exports

exports.gc = (request, reply) => {
const ipfs = request.server.app.ipfs

ipfs.repo.gc((err) => {
if (err) {
return reply({
Message: err.toString(),
Code: 0
}).code(500)
}

reply()
})
}

exports.version = (request, reply) => {
const ipfs = request.server.app.ipfs

Expand Down

0 comments on commit 9fff46f

Please sign in to comment.