From a12ae43dd8cc28fe6b21a4a1cf6ba468ef87bd88 Mon Sep 17 00:00:00 2001 From: Sean McGinnis Date: Tue, 23 Feb 2021 09:00:58 -0600 Subject: [PATCH] Add --overwrite flag to tar extraction (#156) * Add --overwrite flag to tar extraction There are times when previous actions have already extracted at least some files to the cache location. This results in subsequent cache extraction operations to emit errors such as: > /usr/bin/tar: [dest_file_path]: Cannot open: File exists This adds the --overwrite flag to the extract call to force tar to just overwrite these files rather than reporting errors. Signed-off-by: Sean McGinnis * npm run lint-fix & npm run format * ignore macOS Co-authored-by: Sergey Vilgelm --- dist/post_run/index.js | 7 ++++++- dist/run/index.js | 7 ++++++- src/install.ts | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/dist/post_run/index.js b/dist/post_run/index.js index 56f3664..34fdeef 100644 --- a/dist/post_run/index.js +++ b/dist/post_run/index.js @@ -49250,7 +49250,12 @@ function installLint(versionConfig) { repl = /\.zip$/; } else { - extractedDir = yield tc.extractTar(archivePath, process.env.HOME); + // We want to always overwrite files if the local cache already has them + const args = ["xz"]; + if (process.platform.toString() != "darwin") { + args.push("--overwrite"); + } + extractedDir = yield tc.extractTar(archivePath, process.env.HOME, args); } const urlParts = assetURL.split(`/`); const dirName = urlParts[urlParts.length - 1].replace(repl, ``); diff --git a/dist/run/index.js b/dist/run/index.js index b1b86e1..c00fef6 100644 --- a/dist/run/index.js +++ b/dist/run/index.js @@ -49260,7 +49260,12 @@ function installLint(versionConfig) { repl = /\.zip$/; } else { - extractedDir = yield tc.extractTar(archivePath, process.env.HOME); + // We want to always overwrite files if the local cache already has them + const args = ["xz"]; + if (process.platform.toString() != "darwin") { + args.push("--overwrite"); + } + extractedDir = yield tc.extractTar(archivePath, process.env.HOME, args); } const urlParts = assetURL.split(`/`); const dirName = urlParts[urlParts.length - 1].replace(repl, ``); diff --git a/src/install.ts b/src/install.ts index 218c595..19b4df5 100644 --- a/src/install.ts +++ b/src/install.ts @@ -45,7 +45,12 @@ export async function installLint(versionConfig: VersionConfig): Promise extractedDir = await tc.extractZip(archivePath, process.env.HOME) repl = /\.zip$/ } else { - extractedDir = await tc.extractTar(archivePath, process.env.HOME) + // We want to always overwrite files if the local cache already has them + const args = ["xz"] + if (process.platform.toString() != "darwin") { + args.push("--overwrite") + } + extractedDir = await tc.extractTar(archivePath, process.env.HOME, args) } const urlParts = assetURL.split(`/`)