diff --git a/dist/restore/index.js b/dist/restore/index.js index b51c9a7..8dc39e9 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -149504,6 +149504,8 @@ var external_crypto_default = /*#__PURE__*/__nccwpck_require__.n(external_crypto // EXTERNAL MODULE: external "fs/promises" var promises_ = __nccwpck_require__(91943); var promises_default = /*#__PURE__*/__nccwpck_require__.n(promises_); +;// CONCATENATED MODULE: external "stream/promises" +const external_stream_promises_namespaceObject = require("stream/promises"); // EXTERNAL MODULE: external "os" var external_os_ = __nccwpck_require__(70857); var external_os_default = /*#__PURE__*/__nccwpck_require__.n(external_os_); @@ -150783,6 +150785,7 @@ class Workspace { + const HOME = external_os_default().homedir(); const config_CARGO_HOME = process.env.CARGO_HOME || external_path_default().join(HOME, ".cargo"); const STATE_CONFIG = "RUST_CACHE_CONFIG"; @@ -150980,9 +150983,7 @@ class CacheConfig { } keyFiles = sort_and_uniq(keyFiles); for (const file of keyFiles) { - for await (const chunk of external_fs_default().createReadStream(file)) { - hasher.update(chunk); - } + await (0,external_stream_promises_namespaceObject.pipeline)((0,external_fs_.createReadStream)(file), hasher); } keyFiles.push(...parsedKeyFiles); self.keyFiles = sort_and_uniq(keyFiles); @@ -151099,10 +151100,17 @@ async function globFiles(pattern) { const globber = await glob.create(pattern, { followSymbolicLinks: false, }); - // fs.statSync resolve the symbolic link and returns stat for the + // fs.stat resolve the symbolic link and returns stat for the // file it pointed to, so isFile would make sure the resolved // file is actually a regular file. - return (await globber.glob()).filter((file) => external_fs_default().statSync(file).isFile()); + const files = []; + for (const file of await globber.glob()) { + const stats = await promises_default().stat(file); + if (stats.isFile()) { + files.push(file); + } + } + return files; } function sort_and_uniq(a) { return a diff --git a/dist/save/index.js b/dist/save/index.js index ffaf496..3c9703c 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -149506,6 +149506,8 @@ var external_crypto_default = /*#__PURE__*/__nccwpck_require__.n(external_crypto // EXTERNAL MODULE: external "fs/promises" var promises_ = __nccwpck_require__(91943); var promises_default = /*#__PURE__*/__nccwpck_require__.n(promises_); +;// CONCATENATED MODULE: external "stream/promises" +const external_stream_promises_namespaceObject = require("stream/promises"); // EXTERNAL MODULE: external "os" var external_os_ = __nccwpck_require__(70857); var external_os_default = /*#__PURE__*/__nccwpck_require__.n(external_os_); @@ -150783,6 +150785,7 @@ class Workspace { + const HOME = external_os_default().homedir(); const CARGO_HOME = process.env.CARGO_HOME || external_path_default().join(HOME, ".cargo"); const STATE_CONFIG = "RUST_CACHE_CONFIG"; @@ -150980,9 +150983,7 @@ class CacheConfig { } keyFiles = sort_and_uniq(keyFiles); for (const file of keyFiles) { - for await (const chunk of external_fs_default().createReadStream(file)) { - hasher.update(chunk); - } + await (0,external_stream_promises_namespaceObject.pipeline)((0,external_fs_.createReadStream)(file), hasher); } keyFiles.push(...parsedKeyFiles); self.keyFiles = sort_and_uniq(keyFiles); @@ -151099,10 +151100,17 @@ async function globFiles(pattern) { const globber = await glob.create(pattern, { followSymbolicLinks: false, }); - // fs.statSync resolve the symbolic link and returns stat for the + // fs.stat resolve the symbolic link and returns stat for the // file it pointed to, so isFile would make sure the resolved // file is actually a regular file. - return (await globber.glob()).filter((file) => external_fs_default().statSync(file).isFile()); + const files = []; + for (const file of await globber.glob()) { + const stats = await promises_default().stat(file); + if (stats.isFile()) { + files.push(file); + } + } + return files; } function sort_and_uniq(a) { return a diff --git a/src/config.ts b/src/config.ts index d81aa4f..40c89a1 100644 --- a/src/config.ts +++ b/src/config.ts @@ -1,8 +1,9 @@ import * as core from "@actions/core"; import * as glob from "@actions/glob"; import crypto from "crypto"; -import fs from "fs"; -import fs_promises from "fs/promises"; +import fs from "fs/promises"; +import { createReadStream } from "fs"; +import { pipeline } from "stream/promises"; import os from "os"; import path from "path"; import * as toml from "smol-toml"; @@ -178,7 +179,7 @@ export class CacheConfig { for (const cargo_manifest of cargo_manifests) { try { - const content = await fs_promises.readFile(cargo_manifest, { encoding: "utf8" }); + const content = await fs.readFile(cargo_manifest, { encoding: "utf8" }); // Use any since TomlPrimitive is not exposed const parsed = toml.parse(content) as { [key: string]: any }; @@ -225,7 +226,7 @@ export class CacheConfig { const cargo_lock = path.join(workspace.root, "Cargo.lock"); if (await exists(cargo_lock)) { try { - const content = await fs_promises.readFile(cargo_lock, { encoding: "utf8" }); + const content = await fs.readFile(cargo_lock, { encoding: "utf8" }); const parsed = toml.parse(content); if ((parsed.version !== 3 && parsed.version !== 4) || !("package" in parsed)) { @@ -253,9 +254,7 @@ export class CacheConfig { keyFiles = sort_and_uniq(keyFiles); for (const file of keyFiles) { - for await (const chunk of fs.createReadStream(file)) { - hasher.update(chunk); - } + await pipeline(createReadStream(file), hasher); } keyFiles.push(...parsedKeyFiles); @@ -394,10 +393,17 @@ async function globFiles(pattern: string): Promise { const globber = await glob.create(pattern, { followSymbolicLinks: false, }); - // fs.statSync resolve the symbolic link and returns stat for the + // fs.stat resolve the symbolic link and returns stat for the // file it pointed to, so isFile would make sure the resolved // file is actually a regular file. - return (await globber.glob()).filter((file) => fs.statSync(file).isFile()); + const files = []; + for (const file of await globber.glob()) { + const stats = await fs.stat(file); + if (stats.isFile()) { + files.push(file); + } + } + return files; } function sort_and_uniq(a: string[]) {