From dc4db5322a6b31921dabcbef944ac71db1cb80e7 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Fri, 7 Feb 2020 23:14:10 +0000 Subject: [PATCH 1/3] feat: meta for ipfs.get --- src/get.js | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/get.js b/src/get.js index 635f8b34f..bbfde9854 100644 --- a/src/get.js +++ b/src/get.js @@ -39,15 +39,16 @@ module.exports = configure(({ ky }) => { const extractor = Tar.extract() for await (const { header, body } of extractor(toIterable(res.body))) { + const file = { + path: header.name, + mtime: { secs: header.mtime.getTime() }, + mode: header.mode + } + if (header.type === 'directory') { - yield { - path: header.name - } + yield file } else { - yield { - path: header.name, - content: body - } + yield { ...file, content: body } } } } From 37a71561583103a0a7a7e0b41db57c47b77d3132 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Sun, 9 Feb 2020 22:53:03 +0000 Subject: [PATCH 2/3] fix: convert ms to s --- src/get.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/get.js b/src/get.js index bbfde9854..d2d990f09 100644 --- a/src/get.js +++ b/src/get.js @@ -41,7 +41,7 @@ module.exports = configure(({ ky }) => { for await (const { header, body } of extractor(toIterable(res.body))) { const file = { path: header.name, - mtime: { secs: header.mtime.getTime() }, + mtime: { secs: Math.floor(header.mtime.getTime() / 1000) }, mode: header.mode } From f7f6b2fbdc0a00ef4c11438052dfd51790e70cdb Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Sun, 9 Feb 2020 22:56:22 +0000 Subject: [PATCH 3/3] chore: update interface-ipfs-core dep --- package.json | 2 +- test/interface.spec.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 07ad807db..bd69817f5 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "async": "^3.1.0", "browser-process-platform": "~0.1.1", "go-ipfs-dep": "^0.4.23", - "interface-ipfs-core": "^0.131.7", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#test/meta-for-get", "ipfsd-ctl": "^2.1.0", "it-all": "^1.0.1", "it-concat": "^1.0.0", diff --git a/test/interface.spec.js b/test/interface.spec.js index ebec1b0e9..2f0021ba7 100644 --- a/test/interface.spec.js +++ b/test/interface.spec.js @@ -54,6 +54,14 @@ describe('interface-ipfs-core tests', () => { name: 'should export a chunk of a file', reason: 'TODO not implemented in go-ipfs yet' }, + { + name: 'should get file with mtime', + reason: 'TODO not implemented in go-ipfs yet' + }, + { + name: 'should get file with mode', + reason: 'TODO not implemented in go-ipfs yet' + }, { name: 'should ls with metadata', reason: 'TODO not implemented in go-ipfs yet'