Skip to content

Commit

Permalink
chore: remove extra stat call
Browse files Browse the repository at this point in the history
  • Loading branch information
SgtPooki committed Mar 15, 2024
1 parent d1e6a82 commit 07ab941
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions packages/verified-fetch/src/verified-fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,10 @@ export class VerifiedFetch {
}

// we have to .stat before .cat so we can get the size and make sure byte offsets are calculated properly
if (byteRangeContext.isRangeRequest && byteRangeContext.isValidRangeRequest) {
stat = stat ?? await this.unixfs.stat(resolvedCID, {
signal: options?.signal,
onProgress: options?.onProgress
})
this.log.trace('stat.fileSize for rangeRequest %d', stat.fileSize)
byteRangeContext.fileSize = stat.fileSize
if (byteRangeContext.isRangeRequest && byteRangeContext.isValidRangeRequest && terminalElement.type === 'file') {
byteRangeContext.fileSize = terminalElement.unixfs.fileSize()

this.log.trace('fileSize for rangeRequest %d', byteRangeContext.fileSize)
}
const offset = byteRangeContext.offset
const length = byteRangeContext.length
Expand Down

0 comments on commit 07ab941

Please sign in to comment.