From 16019b42a936b7be477b3e75f493d5c949aed961 Mon Sep 17 00:00:00 2001 From: Josh Gross Date: Tue, 17 Dec 2019 17:19:16 -0500 Subject: [PATCH] Fix threads array --- dist/restore/index.js | 2 +- dist/save/index.js | 2 +- src/cacheHttpClient.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 86d20e2..f187667 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -1623,7 +1623,7 @@ function uploadFile(restClient, cacheId, archivePath) { const responses = []; const fd = fs.openSync(archivePath, "r"); // Use the same fd for serial reads? Will this work for parallel too? const concurrency = 4; // # of HTTP requests in parallel - const threads = new Array(concurrency); + const threads = [...new Array(concurrency).keys()]; core.debug("Awaiting all uploads"); let offset = 0; yield Promise.all(threads.map(() => __awaiter(this, void 0, void 0, function* () { diff --git a/dist/save/index.js b/dist/save/index.js index 040fdc3..d447efb 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -1623,7 +1623,7 @@ function uploadFile(restClient, cacheId, archivePath) { const responses = []; const fd = fs.openSync(archivePath, "r"); // Use the same fd for serial reads? Will this work for parallel too? const concurrency = 4; // # of HTTP requests in parallel - const threads = new Array(concurrency); + const threads = [...new Array(concurrency).keys()]; core.debug("Awaiting all uploads"); let offset = 0; yield Promise.all(threads.map(() => __awaiter(this, void 0, void 0, function* () { diff --git a/src/cacheHttpClient.ts b/src/cacheHttpClient.ts index 65ad1f4..a8a22bd 100644 --- a/src/cacheHttpClient.ts +++ b/src/cacheHttpClient.ts @@ -182,7 +182,7 @@ async function uploadFile(restClient: RestClient, cacheId: number, archivePath: const fd = fs.openSync(archivePath, "r"); // Use the same fd for serial reads? Will this work for parallel too? const concurrency = 4; // # of HTTP requests in parallel - const threads = new Array(concurrency); + const threads = [...new Array(concurrency).keys()]; core.debug("Awaiting all uploads"); let offset = 0; await Promise.all(threads.map(async () => { // This might not work cause something something closures