3
0
Fork 0
mirror of https://github.com/Swatinem/rust-cache synced 2025-11-05 15:06:02 +00:00

fix: Move 'if' check for 'add-rust-environment-hash-key' input above keyFiles definition to avoid un-needed computation

This commit is contained in:
Ryan-Brice 2025-11-02 18:52:16 +08:00
parent 967280621f
commit 6424dd79ce
No known key found for this signature in database
GPG key ID: 3702BD1113AFDD13
3 changed files with 233 additions and 230 deletions

View file

@ -148844,6 +148844,9 @@ class CacheConfig {
workspaces.push(new Workspace(root, target));
}
self.workspaces = workspaces;
// Add hash suffix of all rust environment lockfiles + manifests if
// 'add-rust-environment-hash-key' is true
if (lib_core.getInput("add-rust-environment-hash-key").toLowerCase() == "true") {
let keyFiles = await globFiles(".cargo/config.toml\nrust-toolchain\nrust-toolchain.toml");
const parsedKeyFiles = []; // keyFiles that are parsed, pre-processed and hashed
hasher = external_crypto_default().createHash("sha1");
@ -148926,8 +148929,6 @@ class CacheConfig {
}
keyFiles.push(...parsedKeyFiles);
self.keyFiles = sort_and_uniq(keyFiles);
// Add lock hash suffix if 'add-rust-environment-hash-key' is true
if (lib_core.getInput("add-rust-environment-hash-key").toLowerCase() == "true") {
let lockHash = digest(hasher);
key += `-${lockHash}`;
}

5
dist/save/index.js vendored
View file

@ -148844,6 +148844,9 @@ class CacheConfig {
workspaces.push(new Workspace(root, target));
}
self.workspaces = workspaces;
// Add hash suffix of all rust environment lockfiles + manifests if
// 'add-rust-environment-hash-key' is true
if (core.getInput("add-rust-environment-hash-key").toLowerCase() == "true") {
let keyFiles = await globFiles(".cargo/config.toml\nrust-toolchain\nrust-toolchain.toml");
const parsedKeyFiles = []; // keyFiles that are parsed, pre-processed and hashed
hasher = external_crypto_default().createHash("sha1");
@ -148926,8 +148929,6 @@ class CacheConfig {
}
keyFiles.push(...parsedKeyFiles);
self.keyFiles = sort_and_uniq(keyFiles);
// Add lock hash suffix if 'add-rust-environment-hash-key' is true
if (core.getInput("add-rust-environment-hash-key").toLowerCase() == "true") {
let lockHash = digest(hasher);
key += `-${lockHash}`;
}

View file

@ -142,6 +142,9 @@ export class CacheConfig {
}
self.workspaces = workspaces;
// Add hash suffix of all rust environment lockfiles + manifests if
// 'add-rust-environment-hash-key' is true
if (core.getInput("add-rust-environment-hash-key").toLowerCase() == "true") {
let keyFiles = await globFiles(".cargo/config.toml\nrust-toolchain\nrust-toolchain.toml");
const parsedKeyFiles = []; // keyFiles that are parsed, pre-processed and hashed
@ -244,8 +247,6 @@ export class CacheConfig {
keyFiles.push(...parsedKeyFiles);
self.keyFiles = sort_and_uniq(keyFiles);
// Add lock hash suffix if 'add-rust-environment-hash-key' is true
if (core.getInput("add-rust-environment-hash-key").toLowerCase() == "true") {
let lockHash = digest(hasher);
key += `-${lockHash}`;
}