Skip to content

Commit

Permalink
fix: allow collection items with zero size (#947)
Browse files Browse the repository at this point in the history
* fix: allow collection items with zero size

* style: add newline
  • Loading branch information
Cafe137 authored Sep 16, 2024
1 parent cff622e commit e5d9590
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/utils/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function isCollection(data: unknown): data is Collection {
return false
}

return data.every(entry => typeof entry === 'object' && entry.path && entry.size)
return data.every(entry => typeof entry === 'object' && entry.path && entry.size !== undefined)
}

export function assertCollection(data: unknown): asserts data is Collection {
Expand Down
1 change: 1 addition & 0 deletions src/utils/tar.browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class TarStream {

async endFile() {
const padding = this.currentFileSize % 512 === 0 ? 0 : 512 - (this.currentFileSize % 512)

if (padding > 0) {
this.pieces.push(new Uint8Array(padding))
}
Expand Down
1 change: 1 addition & 0 deletions src/utils/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class TarStream {

async endFile() {
const padding = this.currentFileSize % 512 === 0 ? 0 : 512 - (this.currentFileSize % 512)

if (padding > 0) {
this.output.write(Buffer.alloc(padding, 0))
}
Expand Down

0 comments on commit e5d9590

Please sign in to comment.