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 <sean.mcginnis@gmail.com>

* npm run lint-fix & npm run format

* ignore macOS

Co-authored-by: Sergey Vilgelm <sergey.vilgelm@ibm.com>
This commit is contained in:
Sean McGinnis 2021-02-23 09:00:58 -06:00 committed by GitHub
parent f1dee55574
commit a12ae43dd8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -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, ``);

7
dist/run/index.js vendored
View File

@ -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, ``);

View File

@ -45,7 +45,12 @@ export async function installLint(versionConfig: VersionConfig): Promise<string>
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(`/`)