File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -251,9 +251,14 @@ export default class AzureHandler extends RemoteHandlerAbstract {
251
251
if ( typeof file !== 'string' ) {
252
252
file = file . fd
253
253
}
254
- const blobClient = this . #containerClient. getBlobClient ( file )
255
254
try {
256
- const downloadResponse = await blobClient . download ( position , buffer . length )
255
+ const blobClient = this . #containerClient. getBlobClient ( file )
256
+ const blobSize = ( await blobClient . getProperties ( ) ) . contentLength
257
+ if ( position >= blobSize ) {
258
+ throw new Error ( `Requested range starts beyond blob size: ${ blobSize } ` )
259
+ }
260
+
261
+ const downloadResponse = await blobClient . download ( position , Math . min ( blobSize - position , buffer . length ) )
257
262
const bytesRead = await this . #streamToBuffer( downloadResponse . readableStreamBody , buffer )
258
263
return { bytesRead, buffer }
259
264
} catch ( e ) {
You can’t perform that action at this time.
0 commit comments