Skip to content

Commit

Permalink
Add --overwrite flag to tar extraction (#156)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* npm run lint-fix & npm run format

* ignore macOS

Co-authored-by: Sergey Vilgelm <[email protected]>
  • Loading branch information
stmcginnis and Sergey Vilgelm authored Feb 23, 2021
1 parent f1dee55 commit a12ae43
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 6 additions & 1 deletion dist/post_run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ``);
Expand Down
7 changes: 6 additions & 1 deletion dist/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, ``);
Expand Down
7 changes: 6 additions & 1 deletion src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(`/`)
Expand Down

0 comments on commit a12ae43

Please sign in to comment.