From f9263a51b36d99bcc6231f244e069721911a3789 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sat, 5 Nov 2022 11:38:29 -0300 Subject: [PATCH] revert dist change --- dist/restore/index.js | 45 ++++++++++++++++++------------------------- dist/save/index.js | 45 ++++++++++++++++++------------------------- 2 files changed, 38 insertions(+), 52 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 4c18433..2e43c55 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -64603,6 +64603,25 @@ class CacheConfig { // might create/overwrite lockfiles. let lockHash = lib_core.getState(STATE_LOCKFILE_HASH); let keyFiles = JSON.parse(lib_core.getState(STATE_LOCKFILES) || "[]"); + if (!lockHash) { + const globber = await glob.create("**/Cargo.toml\n**/Cargo.lock\nrust-toolchain\nrust-toolchain.toml", { + followSymbolicLinks: false, + }); + keyFiles = await globber.glob(); + keyFiles.sort((a, b) => a.localeCompare(b)); + hasher = external_crypto_default().createHash("sha1"); + for (const file of keyFiles) { + for await (const chunk of external_fs_default().createReadStream(file)) { + hasher.update(chunk); + } + } + lockHash = hasher.digest("hex"); + lib_core.saveState(STATE_LOCKFILE_HASH, lockHash); + lib_core.saveState(STATE_LOCKFILES, JSON.stringify(keyFiles)); + } + self.keyFiles = keyFiles; + key += `-${lockHash}`; + self.cacheKey = key; // Constructs the workspace config and paths to restore: // The workspaces are given using a `$workspace -> $target` syntax. const workspaces = []; @@ -64614,32 +64633,6 @@ class CacheConfig { workspaces.push(new Workspace(root, target)); } self.workspaces = workspaces; - if (!lockHash) { - hasher = external_crypto_default().createHash("sha1"); - async function globHash(pattern) { - const globber = await glob.create(pattern, { - followSymbolicLinks: false, - }); - keyFiles = keyFiles.concat(await globber.glob()); - keyFiles.sort((a, b) => a.localeCompare(b)); - for (const file of keyFiles) { - for await (const chunk of external_fs_default().createReadStream(file)) { - hasher.update(chunk); - } - } - } - await globHash("rust-toolchain\nrust-toolchain.toml"); - for (const workspace of workspaces) { - const root = workspace.root; - await globHash(`${root}/**/Cargo.toml\n${root}/**/Cargo.lock`); - } - lockHash = hasher.digest("hex"); - lib_core.saveState(STATE_LOCKFILE_HASH, lockHash); - lib_core.saveState(STATE_LOCKFILES, JSON.stringify(keyFiles)); - } - self.keyFiles = keyFiles; - key += `-${lockHash}`; - self.cacheKey = key; self.cachePaths = [config_CARGO_HOME]; const cacheTargets = lib_core.getInput("cache-targets").toLowerCase(); if (cacheTargets === "true") { diff --git a/dist/save/index.js b/dist/save/index.js index 941a089..1177027 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -64603,6 +64603,25 @@ class CacheConfig { // might create/overwrite lockfiles. let lockHash = core.getState(STATE_LOCKFILE_HASH); let keyFiles = JSON.parse(core.getState(STATE_LOCKFILES) || "[]"); + if (!lockHash) { + const globber = await glob.create("**/Cargo.toml\n**/Cargo.lock\nrust-toolchain\nrust-toolchain.toml", { + followSymbolicLinks: false, + }); + keyFiles = await globber.glob(); + keyFiles.sort((a, b) => a.localeCompare(b)); + hasher = external_crypto_default().createHash("sha1"); + for (const file of keyFiles) { + for await (const chunk of external_fs_default().createReadStream(file)) { + hasher.update(chunk); + } + } + lockHash = hasher.digest("hex"); + core.saveState(STATE_LOCKFILE_HASH, lockHash); + core.saveState(STATE_LOCKFILES, JSON.stringify(keyFiles)); + } + self.keyFiles = keyFiles; + key += `-${lockHash}`; + self.cacheKey = key; // Constructs the workspace config and paths to restore: // The workspaces are given using a `$workspace -> $target` syntax. const workspaces = []; @@ -64614,32 +64633,6 @@ class CacheConfig { workspaces.push(new Workspace(root, target)); } self.workspaces = workspaces; - if (!lockHash) { - hasher = external_crypto_default().createHash("sha1"); - async function globHash(pattern) { - const globber = await glob.create(pattern, { - followSymbolicLinks: false, - }); - keyFiles = keyFiles.concat(await globber.glob()); - keyFiles.sort((a, b) => a.localeCompare(b)); - for (const file of keyFiles) { - for await (const chunk of external_fs_default().createReadStream(file)) { - hasher.update(chunk); - } - } - } - await globHash("rust-toolchain\nrust-toolchain.toml"); - for (const workspace of workspaces) { - const root = workspace.root; - await globHash(`${root}/**/Cargo.toml\n${root}/**/Cargo.lock`); - } - lockHash = hasher.digest("hex"); - core.saveState(STATE_LOCKFILE_HASH, lockHash); - core.saveState(STATE_LOCKFILES, JSON.stringify(keyFiles)); - } - self.keyFiles = keyFiles; - key += `-${lockHash}`; - self.cacheKey = key; self.cachePaths = [CARGO_HOME]; const cacheTargets = core.getInput("cache-targets").toLowerCase(); if (cacheTargets === "true") {