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

fix(repo): do not hang on calls to repo gc #1377

Merged
merged 1 commit into from
Jun 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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