diff --git a/packages/ipfs-unixfs-exporter/CHANGELOG.md b/packages/ipfs-unixfs-exporter/CHANGELOG.md index a2ea66e8..45d3a7df 100644 --- a/packages/ipfs-unixfs-exporter/CHANGELOG.md +++ b/packages/ipfs-unixfs-exporter/CHANGELOG.md @@ -1,3 +1,10 @@ +## [ipfs-unixfs-exporter-v8.0.3](https://github.com/ipfs/js-ipfs-unixfs/compare/ipfs-unixfs-exporter-v8.0.2...ipfs-unixfs-exporter-v8.0.3) (2022-08-17) + + +### Bug Fixes + +* handle empty files again ([4c1b9f6](https://github.com/ipfs/js-ipfs-unixfs/commit/4c1b9f666a77ffc2bc9f5fbaa6342257052d6e62)) + ## [ipfs-unixfs-exporter-v8.0.2](https://github.com/ipfs/js-ipfs-unixfs/compare/ipfs-unixfs-exporter-v8.0.1...ipfs-unixfs-exporter-v8.0.2) (2022-08-17) diff --git a/packages/ipfs-unixfs-exporter/package.json b/packages/ipfs-unixfs-exporter/package.json index 392ed371..c1c58af0 100644 --- a/packages/ipfs-unixfs-exporter/package.json +++ b/packages/ipfs-unixfs-exporter/package.json @@ -1,6 +1,6 @@ { "name": "ipfs-unixfs-exporter", - "version": "8.0.2", + "version": "8.0.3", "description": "JavaScript implementation of the UnixFs exporter used by IPFS", "license": "Apache-2.0 OR MIT", "homepage": "https://github.com/ipfs/js-ipfs-unixfs/tree/master/packages/ipfs-unixfs-exporter#readme", diff --git a/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js b/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js index b852ff07..128fb0ac 100644 --- a/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js +++ b/packages/ipfs-unixfs-exporter/src/resolvers/unixfs-v1/content/file.js @@ -137,6 +137,10 @@ const fileContent = (cid, node, unixfs, path, resolve, depth, blockstore) => { length } = validateOffsetAndLength(fileSize, options.offset, options.length) + if (length === 0) { + return + } + const queue = pushable({ objectMode: true }) diff --git a/packages/ipfs-unixfs-exporter/test/exporter.spec.js b/packages/ipfs-unixfs-exporter/test/exporter.spec.js index 290fd19d..e54cbcd4 100644 --- a/packages/ipfs-unixfs-exporter/test/exporter.spec.js +++ b/packages/ipfs-unixfs-exporter/test/exporter.spec.js @@ -686,6 +686,14 @@ describe('exporter', () => { expect(data).to.deep.equal(bigFile) }) + it('reads an empty file', async () => { + const data = await addAndReadTestFile({ + file: new Uint8Array() + }) + + expect(data).to.have.property('byteLength', 0) + }) + it('returns an empty stream for dir', async () => { const imported = await first(importer([{ path: 'empty'