mirror of
https://github.com/DeterminateSystems/nix-installer-action.git
synced 2025-01-10 22:32:06 +01:00
retries: autoClose, but open file with O_SYNC
This commit is contained in:
parent
d46d5b144a
commit
bb22c86823
3 changed files with 14 additions and 9 deletions
9
dist/index.js
vendored
9
dist/index.js
vendored
|
@ -333,15 +333,16 @@ 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 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}`);
|
const tempfile = (0,node_path__WEBPACK_IMPORTED_MODULE_5__.join)(tempdir, `nix-installer-${this.platform}`);
|
||||||
if (response.body !== null) {
|
if (response.body !== null) {
|
||||||
const handle = await (0,node_fs_promises__WEBPACK_IMPORTED_MODULE_2__.open)(tempfile, "w");
|
const handle = await (0,node_fs_promises__WEBPACK_IMPORTED_MODULE_2__.open)(tempfile, (node_fs__WEBPACK_IMPORTED_MODULE_9___default().constants.O_CREAT) |
|
||||||
const fileStream = handle.createWriteStream({ autoClose: false });
|
(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_DSYNC));
|
||||||
|
const fileStream = handle.createWriteStream();
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const bodyCast = response.body;
|
const bodyCast = response.body;
|
||||||
const bodyReader = node_stream__WEBPACK_IMPORTED_MODULE_7___default().Readable.fromWeb(bodyCast);
|
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));
|
await (0,node_stream_promises__WEBPACK_IMPORTED_MODULE_8__.finished)(bodyReader.pipe(fileStream));
|
||||||
fileStream.close();
|
fileStream.close();
|
||||||
await handle.sync();
|
|
||||||
await handle.close();
|
|
||||||
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Downloaded \`nix-installer\` to \`${tempfile}\``);
|
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Downloaded \`nix-installer\` to \`${tempfile}\``);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
12
src/main.ts
12
src/main.ts
|
@ -432,15 +432,19 @@ class NixInstallerAction {
|
||||||
const tempfile = join(tempdir, `nix-installer-${this.platform}`);
|
const tempfile = join(tempdir, `nix-installer-${this.platform}`);
|
||||||
|
|
||||||
if (response.body !== null) {
|
if (response.body !== null) {
|
||||||
const handle = await open(tempfile, "w");
|
const handle = await open(
|
||||||
const fileStream = handle.createWriteStream({ autoClose: false });
|
tempfile,
|
||||||
|
fs.constants.O_CREAT |
|
||||||
|
fs.constants.O_TRUNC |
|
||||||
|
fs.constants.O_WRONLY |
|
||||||
|
fs.constants.O_DSYNC,
|
||||||
|
);
|
||||||
|
const fileStream = handle.createWriteStream();
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const bodyCast = response.body as stream_web.ReadableStream<any>;
|
const bodyCast = response.body as stream_web.ReadableStream<any>;
|
||||||
const bodyReader = stream.Readable.fromWeb(bodyCast);
|
const bodyReader = stream.Readable.fromWeb(bodyCast);
|
||||||
await finished(bodyReader.pipe(fileStream));
|
await finished(bodyReader.pipe(fileStream));
|
||||||
fileStream.close();
|
fileStream.close();
|
||||||
await handle.sync();
|
|
||||||
await handle.close();
|
|
||||||
|
|
||||||
actions_core.info(`Downloaded \`nix-installer\` to \`${tempfile}\``);
|
actions_core.info(`Downloaded \`nix-installer\` to \`${tempfile}\``);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue