Skip to content

Commit 011ac76

Browse files
authored
@tus/s3-store: fix offset NaN when there are no parts (#784)
Closes #783
1 parent 688a578 commit 011ac76

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

.changeset/nasty-drinks-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@tus/s3-store": patch
3+
---
4+
5+
Fix offset being returned as `NaN` when there are no S3 parts found

packages/s3-store/src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ export type MetadataValue = {
5656
}
5757

5858
function calcOffsetFromParts(parts?: Array<AWS.Part>) {
59-
// @ts-expect-error not undefined
60-
return parts && parts.length > 0 ? parts.reduce((a, b) => a + b.Size, 0) : 0
59+
return parts && parts.length > 0 ? parts.reduce((a, b) => a + (b.Size ?? 0), 0) : 0
6160
}
6261

6362
// Implementation (based on https://github.com/tus/tusd/blob/master/s3store/s3store.go)

0 commit comments

Comments
 (0)