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

Commit 9fff46f

Browse files
alanshawdaviddias
authored andcommitted
fix(repo): do not hang on calls to repo gc
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 <[email protected]>
1 parent 097edd5 commit 9fff46f

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/cli/commands/repo/gc.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@
33
module.exports = {
44
command: 'gc',
55

6-
describe: '',
6+
describe: 'Perform a garbage collection sweep on the repo.',
77

88
builder: {},
99

1010
handler (argv) {
11+
argv.ipfs.repo.gc((err) => {
12+
if (err) {
13+
throw err
14+
}
15+
})
1116
}
1217
}

src/core/components/repo.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ module.exports = function repo (self) {
3838
})
3939
}),
4040

41-
gc: () => {},
41+
gc: promisify((options, callback) => {
42+
if (typeof options === 'function') {
43+
callback = options
44+
options = {}
45+
}
46+
47+
callback(new Error('Not implemented'))
48+
}),
4249

4350
stat: promisify((options, callback) => {
4451
if (typeof options === 'function') {

src/http/api/resources/repo.js

+15
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,21 @@
22

33
exports = module.exports
44

5+
exports.gc = (request, reply) => {
6+
const ipfs = request.server.app.ipfs
7+
8+
ipfs.repo.gc((err) => {
9+
if (err) {
10+
return reply({
11+
Message: err.toString(),
12+
Code: 0
13+
}).code(500)
14+
}
15+
16+
reply()
17+
})
18+
}
19+
520
exports.version = (request, reply) => {
621
const ipfs = request.server.app.ipfs
722

0 commit comments

Comments
 (0)