mirror of
				https://github.com/actions/cache.git
				synced 2025-11-04 13:29:10 +08:00 
			
		
		
		
	Fix upload chunk retries
This commit is contained in:
		@@ -206,7 +206,7 @@ function getContentRange(start: number, end: number): string {
 | 
			
		||||
async function uploadChunk(
 | 
			
		||||
    httpClient: HttpClient,
 | 
			
		||||
    resourceUrl: string,
 | 
			
		||||
    data: NodeJS.ReadableStream,
 | 
			
		||||
    openStream: () => NodeJS.ReadableStream,
 | 
			
		||||
    start: number,
 | 
			
		||||
    end: number
 | 
			
		||||
): Promise<void> {
 | 
			
		||||
@@ -227,7 +227,7 @@ async function uploadChunk(
 | 
			
		||||
        return await httpClient.sendStream(
 | 
			
		||||
            "PATCH",
 | 
			
		||||
            resourceUrl,
 | 
			
		||||
            data,
 | 
			
		||||
            openStream(),
 | 
			
		||||
            additionalHeaders
 | 
			
		||||
        );
 | 
			
		||||
    };
 | 
			
		||||
@@ -290,17 +290,17 @@ async function uploadFile(
 | 
			
		||||
                    const start = offset;
 | 
			
		||||
                    const end = offset + chunkSize - 1;
 | 
			
		||||
                    offset += MAX_CHUNK_SIZE;
 | 
			
		||||
                    const chunk = fs.createReadStream(archivePath, {
 | 
			
		||||
                        fd,
 | 
			
		||||
                        start,
 | 
			
		||||
                        end,
 | 
			
		||||
                        autoClose: false
 | 
			
		||||
                    });
 | 
			
		||||
 | 
			
		||||
                    await uploadChunk(
 | 
			
		||||
                        httpClient,
 | 
			
		||||
                        resourceUrl,
 | 
			
		||||
                        chunk,
 | 
			
		||||
                        () =>
 | 
			
		||||
                            fs.createReadStream(archivePath, {
 | 
			
		||||
                                fd,
 | 
			
		||||
                                start,
 | 
			
		||||
                                end,
 | 
			
		||||
                                autoClose: false
 | 
			
		||||
                            }),
 | 
			
		||||
                        start,
 | 
			
		||||
                        end
 | 
			
		||||
                    );
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user