3
0
Fork 0
mirror of https://code.forgejo.org/actions/cache.git synced 2025-04-23 03:45:31 +00:00

Fix upload chunk retries

This commit is contained in:
Dave Hadka 2020-05-11 10:49:48 -04:00 committed by Aiqiao Yan
parent ec7f7ebd08
commit da9f90cb83
3 changed files with 153 additions and 85 deletions

View file

@ -179,7 +179,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> {
@ -200,7 +200,7 @@ async function uploadChunk(
return await httpClient.sendStream(
"PATCH",
resourceUrl,
data,
openStream(),
additionalHeaders
);
};
@ -263,17 +263,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
);