File tree Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Expand file tree Collapse file tree 2 files changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ export class DownloadAgent {
104
104
const { contentLength, isAcceptRanges } = parseRangeInfo ( response . headers )
105
105
ranges = contentLength && isAcceptRanges
106
106
? this . rangePolicy . computeRanges ( contentLength )
107
- : [ { start : 0 , end : contentLength } ]
107
+ : [ { start : 0 , end : contentLength - 1 } ]
108
108
targetUrl = new URL ( location )
109
109
total = contentLength
110
110
await handle . truncate ( total )
Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ export async function * range(
56
56
57
57
let nextUrl = url
58
58
while ( true ) {
59
+ if ( segment . start >= segment . end ) {
60
+ // the segment is finished, just ignore it
61
+ return
62
+ }
59
63
try {
60
64
const { opaque } = await stream ( nextUrl , {
61
65
method : 'GET' ,
@@ -84,7 +88,10 @@ export async function * range(
84
88
}
85
89
if ( typeof responseHeaders [ 'content-length' ] === 'string' ) {
86
90
contentLength = Number . parseInt ( responseHeaders [ 'content-length' ] ?? '0' )
87
- segment . end = contentLength
91
+ const end = segment . start + contentLength - 1
92
+ if ( end !== segment . end ) {
93
+ segment . end = segment . start + contentLength
94
+ }
88
95
}
89
96
return ( opaque as any ) . fileStream as Writable
90
97
} )
You can’t perform that action at this time.
0 commit comments