Skip to content

Commit

Permalink
If fs.renameSync fails (e.g. because source and destination files a…
Browse files Browse the repository at this point in the history
…re on different partitions), try `fs.copySync` and `fs.unlinkSync` instead.
  • Loading branch information
rcannood committed Jun 15, 2023
1 parent 519edf8 commit 6306aab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## Changed

- If `fs.renameSync` fails (e.g. because source and destination files are on different partitions), try `fs.copySync` and `fs.unlinkSync` instead.

## [1.3.0] - 2023-05-19

## Changed
Expand Down
8 changes: 7 additions & 1 deletion src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,13 @@ export async function install_nextflow(
const temp_install_dir = fs.mkdtempSync(`nxf-${version}`)
const nf_path = `${temp_install_dir}/nextflow`

fs.renameSync(nf_dl_path, nf_path)
try {
fs.renameSync(nf_dl_path, nf_path)
} catch (err: unknown) {
core.debug(`Failed to rename file: ${err}`)
fs.copyFileSync(nf_dl_path, nf_path)
fs.unlinkSync(nf_dl_path)
}
fs.chmodSync(nf_path, "0711")

return temp_install_dir
Expand Down

0 comments on commit 6306aab

Please sign in to comment.