Skip to content

Commit 11be43d

Browse files
committed
fix: handle the case in read where blob size is 0
1 parent ceca39a commit 11be43d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

@xen-orchestra/fs/src/azure.js

+7
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@ export default class AzureHandler extends RemoteHandlerAbstract {
242242
}
243243

244244
async _getSize(file) {
245+
if (typeof file !== 'string') {
246+
file = file.fd
247+
}
245248
const blobClient = this.#containerClient.getBlobClient(file)
246249
const properties = await blobClient.getProperties()
247250
return properties.contentLength
@@ -254,6 +257,10 @@ export default class AzureHandler extends RemoteHandlerAbstract {
254257
try {
255258
const blobClient = this.#containerClient.getBlobClient(file)
256259
const blobSize = (await blobClient.getProperties()).contentLength
260+
if (blobSize === 0) {
261+
console.warn(`Blob is empty: ${file}`)
262+
return { bytesRead: 0, buffer }
263+
}
257264
if (position >= blobSize) {
258265
throw new Error(`Requested range starts beyond blob size: ${blobSize}`)
259266
}

0 commit comments

Comments
 (0)