@@ -281,6 +281,14 @@ runCmdContent = (cmdfn) -> (res) ->
281
281
# pinbot implementation
282
282
module .exports = (robot ) ->
283
283
284
+ resolveToCid = (res , path , cb ) ->
285
+ ipfs .resolve path, {r : true }, mustSucceed res, (path2 ) ->
286
+ if path2 .substr (0 , 6 ) != ' /ipfs/'
287
+ return reportFail res, ' failed to resolve path. got: ' + path2
288
+ cid = path2 .substr (6 )
289
+ console .log (' resolve' , path, path2, cid)
290
+ cb (cid)
291
+
284
292
# NODE INFO
285
293
robot .respond / ipfs api-info/ i , (res ) ->
286
294
res .send """
@@ -317,12 +325,13 @@ module.exports = (robot) ->
317
325
# FILE COMMANDS
318
326
robot .respond / ipfs files read (\S + )/ i , runCmdContent ipfs .files .read
319
327
robot .respond / ipfs files stat (\S + )/ i , runCmd ipfs .files .stat
320
- robot .respond / ipfs files ls (\S )? / i , runCmd ipfs .files .ls ,
328
+ robot .respond / ipfs files ls (\S + )? / i , runCmd ipfs .files .ls ,
321
329
output : (o ) -> _ .pluck (o, ' name' ).join (' \n ' )
322
330
323
331
# NAME COMMANDS
332
+ robot .respond / ipfs resolve (\S + )/ i , runCmdPath ipfs .resolve
324
333
robot .respond / ipfs name resolve (\S + )/ i , runCmd ipfs .name .resolve
325
- robot .respond / ipfs dns (\S + )/ i , runCmd ipfs .dns . resolve
334
+ robot .respond / ipfs dns (\S + )/ i , runCmd ipfs .dns
326
335
327
336
# REPO AND PINNING COMMANDS
328
337
robot .respond / ipfs repo version/ i , runCmd ipfs .repo .version
@@ -334,12 +343,13 @@ module.exports = (robot) ->
334
343
testApi res, ->
335
344
res .send " pinning #{ prettyPath path} (warning: experimental)"
336
345
# todo: implement -r=false support (right now it assumes -r=true)
337
- ipfs .refs path, {r : true }, mustSucceed res, (r ) ->
338
- ipfs .pin .add path, {r : true }, mustSucceed res, (r ) ->
339
- res .send """
340
- success: pinned recursively: #{ prettyPath path}
341
- (warning: this pinbot is experimental. do not rely on me yet.)
342
- """
346
+ resolveToCid res, path, (cid ) ->
347
+ ipfs .refs cid, {r : true }, mustSucceed res, (r ) ->
348
+ ipfs .pin .add cid, {r : true }, mustSucceed res, (r ) ->
349
+ res .send """
350
+ success: pinned recursively: #{ prettyPath path}
351
+ (warning: this pinbot is experimental. do not rely on me yet.)
352
+ """
343
353
344
354
robot .respond / ipfs pin ls (\S + )/ i , runCmdPath ipfs .pin .ls ,
345
355
output : (o ) -> o .map ((e ) -> " #{ e .hash } #{ e .type } " ).join (' \n ' )
0 commit comments