@@ -6,11 +6,12 @@ import { DownloadStreamer } from './DownloadStreamer'
6
6
import type { GETRequestConfig } from '../request'
7
7
8
8
export class DownloadManger {
9
- readonly metadata : Metadata
10
- readonly requestConfig : GETRequestConfig
11
- readonly workers : DownloadWorker [ ]
12
- readonly rangeProvider : RangeProvider
13
- readonly streamer : DownloadStreamer
9
+ private readonly metadata : Metadata
10
+ private readonly requestConfig : GETRequestConfig
11
+ private readonly workers : DownloadWorker [ ]
12
+ private readonly rangeProvider : RangeProvider
13
+ private readonly streamer : DownloadStreamer
14
+ readonly response : Response
14
15
15
16
constructor ( requestConfig : GETRequestConfig , metadata : Metadata ) {
16
17
this . requestConfig = requestConfig
@@ -25,15 +26,13 @@ export class DownloadManger {
25
26
requestConfig . logger . info ( `Content length: ${ contentLength } ` )
26
27
27
28
this . streamer = new DownloadStreamer ( this . rangeProvider . maxRangeIndex , requestConfig ?. init ?. signal )
28
- }
29
29
30
- async fetch ( ) : Promise < Response > {
31
30
void this . startFetching ( )
32
- return new Response ( this . streamer . ReadableStream , this . metadata )
31
+ this . response = new Response ( this . streamer . ReadableStream , this . metadata )
33
32
}
34
33
35
34
// start fetching
36
- async startFetching ( ) : Promise < void > {
35
+ private async startFetching ( ) : Promise < void > {
37
36
this . requestConfig . logger . info ( 'Start fetching.' )
38
37
39
38
const promises = this . workers . map ( async ( worker , idx ) =>
0 commit comments