|
|
|
@ -184,21 +184,24 @@ export async function saveCache(
|
|
|
|
|
// Upload Chunks
|
|
|
|
|
const fileSize = fs.statSync(archivePath).size;
|
|
|
|
|
const resourceUrl = getCacheApiUrl() + "caches/" + cacheId.toString();
|
|
|
|
|
const uploads: Promise<IRestResponse<void>>[] = [];
|
|
|
|
|
const uploads: IRestResponse<void>[] = [];
|
|
|
|
|
|
|
|
|
|
const fd = fs.openSync(archivePath, "r"); // Use the same fd for serial reads? Will this work for parallel too?
|
|
|
|
|
let offset = 0;
|
|
|
|
|
while (offset < fileSize) {
|
|
|
|
|
const chunkSize = offset + MAX_CHUNK_SIZE > fileSize ? fileSize - offset : MAX_CHUNK_SIZE;
|
|
|
|
|
const end = offset + chunkSize - 1;
|
|
|
|
|
core.debug(`Offset: ${offset}`);
|
|
|
|
|
const chunk = fs.createReadStream(archivePath, { start: offset, end });
|
|
|
|
|
uploads.push(uploadChunk(restClient, resourceUrl, chunk, offset, end));
|
|
|
|
|
const chunk = fs.createReadStream(archivePath, { fd, start: offset, end });
|
|
|
|
|
uploads.push(await uploadChunk(restClient, resourceUrl, chunk, offset, end)); // Making this serial
|
|
|
|
|
offset += MAX_CHUNK_SIZE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fs.closeSync(fd);
|
|
|
|
|
|
|
|
|
|
core.debug("Awaiting all uploads");
|
|
|
|
|
const responses = await Promise.all(uploads);
|
|
|
|
|
//const responses = await Promise.all(uploads);
|
|
|
|
|
|
|
|
|
|
const failedResponse = responses.find(
|
|
|
|
|
const failedResponse = uploads.find(
|
|
|
|
|
x => !isSuccessStatusCode(x.statusCode)
|
|
|
|
|
);
|
|
|
|
|
if (failedResponse) {
|
|
|
|
|