Skip to content

Commit

Permalink
retries: and now again without the filehandle close
Browse files Browse the repository at this point in the history
  • Loading branch information
colemickens committed Oct 24, 2023
1 parent d46d5b1 commit e371685
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
10 changes: 6 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,15 +333,17 @@ class NixInstallerAction {
const tempdir = await (0,node_fs_promises__WEBPACK_IMPORTED_MODULE_2__.mkdtemp)((0,node_path__WEBPACK_IMPORTED_MODULE_5__.join)((0,node_os__WEBPACK_IMPORTED_MODULE_6__.tmpdir)(), "nix-installer-"));
const tempfile = (0,node_path__WEBPACK_IMPORTED_MODULE_5__.join)(tempdir, `nix-installer-${this.platform}`);
if (response.body !== null) {
const handle = await (0,node_fs_promises__WEBPACK_IMPORTED_MODULE_2__.open)(tempfile, "w");
const fileStream = handle.createWriteStream({ autoClose: false });
const handle = await (0,node_fs_promises__WEBPACK_IMPORTED_MODULE_2__.open)(tempfile, (node_fs__WEBPACK_IMPORTED_MODULE_9___default().constants.O_CREAT) |
(node_fs__WEBPACK_IMPORTED_MODULE_9___default().constants.O_TRUNC) |
(node_fs__WEBPACK_IMPORTED_MODULE_9___default().constants.O_WRONLY) |
(node_fs__WEBPACK_IMPORTED_MODULE_9___default().constants.O_DIRECT) |
(node_fs__WEBPACK_IMPORTED_MODULE_9___default().constants.O_DSYNC));
const fileStream = handle.createWriteStream();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const bodyCast = response.body;
const bodyReader = node_stream__WEBPACK_IMPORTED_MODULE_7___default().Readable.fromWeb(bodyCast);
await (0,node_stream_promises__WEBPACK_IMPORTED_MODULE_8__.finished)(bodyReader.pipe(fileStream));
fileStream.close();
await handle.sync();
await handle.close();
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Downloaded \`nix-installer\` to \`${tempfile}\``);
}
else {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,15 +432,20 @@ class NixInstallerAction {
const tempfile = join(tempdir, `nix-installer-${this.platform}`);

if (response.body !== null) {
const handle = await open(tempfile, "w");
const fileStream = handle.createWriteStream({ autoClose: false });
const handle = await open(
tempfile,
fs.constants.O_CREAT |
fs.constants.O_TRUNC |
fs.constants.O_WRONLY |
fs.constants.O_DIRECT |
fs.constants.O_DSYNC,
);
const fileStream = handle.createWriteStream();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const bodyCast = response.body as stream_web.ReadableStream<any>;
const bodyReader = stream.Readable.fromWeb(bodyCast);
await finished(bodyReader.pipe(fileStream));
fileStream.close();
await handle.sync();
await handle.close();

actions_core.info(`Downloaded \`nix-installer\` to \`${tempfile}\``);
} else {
Expand Down

0 comments on commit e371685

Please sign in to comment.