Skip to content

Commit

Permalink
Fix invalid array
Browse files Browse the repository at this point in the history
  • Loading branch information
Josh Gross committed Jan 6, 2020
1 parent 4c4974a commit cf4f44d
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/cacheHttpClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,19 @@ async function uploadFile(
const resourceUrl = getCacheApiUrl() + "caches/" + cacheId.toString();
const fd = fs.openSync(archivePath, "r");

const concurrency = Number(process.env["CACHE_UPLOAD_CONCURRENCY"]) ?? 4; // # of HTTP requests in parallel
const MAX_CHUNK_SIZE =
Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]) ?? 32 * 1024 * 1024; // 32 MB Chunks
core.debug(`Concurrency: ${concurrency} and Chunk Size: ${MAX_CHUNK_SIZE}`);
let concurrency = Number(process.env["CACHE_UPLOAD_CONCURRENCY"]); // # of HTTP requests in parallel
if (Number.isNaN(concurrency) || concurrency < 0) {
concurrency = 4;
}

let MAX_CHUNK_SIZE =
Number(process.env["CACHE_UPLOAD_CHUNK_SIZE"]);

if (Number.isNaN(MAX_CHUNK_SIZE) || MAX_CHUNK_SIZE < 0) {
concurrency = 32 * 1024 * 1024; // 32 MB Chunks
}

core.debug(`Concurrency: ${concurrency} and Chunk Size: ${MAX_CHUNK_SIZE}`);
const parallelUploads = [...new Array(concurrency).keys()];
core.debug("Awaiting all uploads");
let offset = 0;
Expand Down

0 comments on commit cf4f44d

Please sign in to comment.