Skip to content

Commit 6861429

Browse files
authored
Fix memory cache population (#448)
* refactor: optimize byte range handling in memory download cache * refactor: remove unnecessary logging in memory download cache * refactor: improve byte range handling in memory download cache to ensure correct subarray extraction
1 parent e2b5a42 commit 6861429

File tree

1 file changed

+3
-5
lines changed
  • backend/src/infrastructure/services/download/memoryDownloadCache

1 file changed

+3
-5
lines changed

backend/src/infrastructure/services/download/memoryDownloadCache/index.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,9 @@ const get = (cid: string, options?: DownloadServiceOptions) => {
2525
const byteRange = options?.byteRange ?? [0, value.length - 1]
2626

2727
return bufferToAsyncIterable(
28-
Buffer.from(
29-
value.buffer.slice(
30-
byteRange[0],
31-
byteRange[1] !== undefined ? byteRange[1] + 1 : undefined,
32-
),
28+
value.subarray(
29+
byteRange[0],
30+
byteRange[1] !== undefined ? byteRange[1] + 1 : undefined,
3331
),
3432
)
3533
}

0 commit comments

Comments
 (0)