@@ -127,12 +127,12 @@ export default class RemoteFile implements GenericFilehandle {
127
127
const totalBytes = contentLength ? parseInt ( contentLength , 10 ) : undefined
128
128
129
129
// Use ReadableStream API for progress reporting if statusCallback is provided
130
- if ( statusCallback && res . body ) {
130
+ if ( statusCallback && res . body && totalBytes ) {
131
131
const reader = res . body . getReader ( )
132
132
const chunks : Uint8Array [ ] = [ ]
133
133
let receivedBytes = 0
134
134
135
- // eslint-disable-next-line no-constant -condition
135
+ // eslint-disable-next-line @typescript-eslint/ no-unnecessary -condition
136
136
while ( true ) {
137
137
const { done, value } = await reader . read ( )
138
138
@@ -143,11 +143,9 @@ export default class RemoteFile implements GenericFilehandle {
143
143
chunks . push ( value )
144
144
receivedBytes += value . length
145
145
146
- if ( statusCallback && totalBytes ) {
147
- statusCallback (
148
- `Downloading ${ getProgressDisplayStr ( receivedBytes , totalBytes ) } ` ,
149
- )
150
- }
146
+ statusCallback (
147
+ `Downloading ${ getProgressDisplayStr ( receivedBytes , totalBytes ) } ` ,
148
+ )
151
149
}
152
150
153
151
// Concatenate chunks
@@ -243,7 +241,7 @@ export default class RemoteFile implements GenericFilehandle {
243
241
const chunks : Uint8Array [ ] = [ ]
244
242
let receivedBytes = 0
245
243
246
- // eslint-disable-next-line no-constant -condition
244
+ // eslint-disable-next-line @typescript-eslint/ no-unnecessary -condition
247
245
while ( true ) {
248
246
const { done, value } = await reader . read ( )
249
247
@@ -259,7 +257,7 @@ export default class RemoteFile implements GenericFilehandle {
259
257
)
260
258
}
261
259
262
- if ( encoding === 'utf8' ) {
260
+ if ( encoding === 'utf8' || encoding === 'utf-8' ) {
263
261
const decoder = new TextDecoder ( 'utf-8' )
264
262
return decoder . decode ( concatUint8Array ( chunks ) )
265
263
} else if ( encoding ) {
@@ -268,8 +266,7 @@ export default class RemoteFile implements GenericFilehandle {
268
266
return concatUint8Array ( chunks )
269
267
}
270
268
} else {
271
- // If no statusCallback, use the simpler approach
272
- if ( encoding === 'utf8' ) {
269
+ if ( encoding === 'utf8' || encoding === 'utf-8' ) {
273
270
return res . text ( )
274
271
} else if ( encoding ) {
275
272
throw new Error ( `unsupported encoding: ${ encoding } ` )
0 commit comments