Skip to content

Commit

Permalink
fix: no content case
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Mar 11, 2022
1 parent fdc7e34 commit fd75c19
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/file/chunker.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ export const close = state => {

switch (state.status) {
case "none": {
return chunks.length === 1
? { single: true, chunk: chunks[0] }
return chunks.length <= 1
? { single: true, chunk: buffer }
: { single: false, chunks }
}
case "single": {
Expand Down Expand Up @@ -187,7 +187,7 @@ export const split = (input, chunker, byteOffset, end) => {
}
buffer =
offset === buffer.byteLength
? BufferQueue.empty()
? buffer
: offset === 0
? buffer
: buffer.subarray(offset)
Expand Down
7 changes: 4 additions & 3 deletions test/convergence.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const createTest = spec =>
const { writer, ...importer } = FileImporter.createImporter({}, config)
const source = await unpackFile(config.url)

// const car = encodeCar(importer.blocks)
// const file = writeFile("temp.car", car)
const ready = collect(importer.blocks)
const car = encodeCar(importer.blocks)
const ready = writeFile("temp.car", car)
// const ready = collect(importer.blocks)

// @ts-expect-error - see https://github.com/DefinitelyTyped/DefinitelyTyped/pull/59057
const stream = /** @type {ReadableStream<Uint8Array>} */ (source.stream())
Expand Down Expand Up @@ -84,6 +84,7 @@ const isDisabledTest = config =>
const tesSet = log => new Set(log.trim().split("\n"))

const only = tesSet(`
jsipfs add --chunker=size-65535 --trickle=false --raw-leaves=false --cid-version=1 ../testdata/zero_0B.zst
`)

const timeouts = tesSet(`
Expand Down

0 comments on commit fd75c19

Please sign in to comment.