From bdbd8b81c2a953b0e3c0fb02fbc64865b1226eeb Mon Sep 17 00:00:00 2001 From: eric sciple Date: Thu, 12 Dec 2019 12:54:40 -0500 Subject: [PATCH] . --- dist/index.js | 12 ++++++++++-- src/github-api-helper.ts | 8 ++++++-- src/retry-helper.ts | 3 +++ 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index 05b6ac3..44395ac 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8438,7 +8438,12 @@ function downloadRepository(accessToken, owner, repo, ref, commit, repositoryPat for (const fileName of yield fs.promises.readdir(tempRepositoryPath)) { const sourcePath = path.join(tempRepositoryPath, fileName); const targetPath = path.join(repositoryPath, fileName); - yield io.mv(sourcePath, targetPath); + if (IS_WINDOWS) { + yield io.cp(sourcePath, targetPath); // Copy on Windows in case Windows Defender has a lock on the files + } + else { + yield io.mv(sourcePath, targetPath); + } } io.rmRF(extractPath); }); @@ -8455,7 +8460,7 @@ function downloadArchive(accessToken, owner, repo, ref, commit) { }; const response = yield octokit.repos.getArchiveLink(params); if (response.status != 200) { - throw new Error(`Unexpected response from GitHub API. Status: '${response.status}'`); + throw new Error(`Unexpected response from GitHub API. Status: ${response.status}, Data: ${response.data}`); } return Buffer.from(response.data); // response.data is ArrayBuffer }); @@ -9802,6 +9807,9 @@ class RetryHelper { this.maxAttempts = maxAttempts; this.minSeconds = Math.floor(minSeconds); this.maxSeconds = Math.floor(maxSeconds); + if (this.minSeconds > this.maxAttempts) { + throw new Error('min seconds should be less than or equal to max seconds'); + } } execute(action) { return __awaiter(this, void 0, void 0, function* () { diff --git a/src/github-api-helper.ts b/src/github-api-helper.ts index 63ec788..ce94701 100644 --- a/src/github-api-helper.ts +++ b/src/github-api-helper.ts @@ -58,7 +58,11 @@ export async function downloadRepository( for (const fileName of await fs.promises.readdir(tempRepositoryPath)) { const sourcePath = path.join(tempRepositoryPath, fileName) const targetPath = path.join(repositoryPath, fileName) - await io.mv(sourcePath, targetPath) + if (IS_WINDOWS) { + await io.cp(sourcePath, targetPath) // Copy on Windows in case Windows Defender has a lock on the files + } else { + await io.mv(sourcePath, targetPath) + } } io.rmRF(extractPath) } @@ -80,7 +84,7 @@ async function downloadArchive( const response = await octokit.repos.getArchiveLink(params) if (response.status != 200) { throw new Error( - `Unexpected response from GitHub API. Status: '${response.status}'` + `Unexpected response from GitHub API. Status: ${response.status}, Data: ${response.data}` ) } diff --git a/src/retry-helper.ts b/src/retry-helper.ts index 0d9e4e9..f99c533 100644 --- a/src/retry-helper.ts +++ b/src/retry-helper.ts @@ -17,6 +17,9 @@ export class RetryHelper { this.maxAttempts = maxAttempts this.minSeconds = Math.floor(minSeconds) this.maxSeconds = Math.floor(maxSeconds) + if (this.minSeconds > this.maxAttempts) { + throw new Error('min seconds should be less than or equal to max seconds') + } } async execute(action: () => Promise): Promise {