Skip to content

Commit

Permalink
adjust key computation to avoid trailing -
Browse files Browse the repository at this point in the history
The `-` suffix was being applied unconditionally resulting in a hanging
`-` suffix if no timestamp was used. Adjust the key computation to
remove the trailing `-` if no timestamp is used.
  • Loading branch information
compnerd committed Feb 27, 2024
1 parent faf867a commit 92af2b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/restore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ async function restore(ccacheVariant : string) : Promise<void> {
restoreKeys: core.getInput("restore-keys").split("\n").map(s => s.trim()).filter(x => x !== "")
};

const keyPrefix = ccacheVariant + "-";
const primaryKey = inputs.primaryKey ? keyPrefix + inputs.primaryKey + "-" : keyPrefix;
const restoreKeys = inputs.restoreKeys.map(k => keyPrefix + k + "-")
const keyPrefix = ccacheVariant;
const primaryKey = inputs.primaryKey ? keyPrefix + "-" + inputs.primaryKey : keyPrefix;
const restoreKeys = inputs.restoreKeys.map(k => keyPrefix + "-" + k)
const paths = [`.${ccacheVariant}`];

core.saveState("primaryKey", primaryKey);
Expand Down
2 changes: 1 addition & 1 deletion src/save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function run() : Promise<void> {
} else {
let saveKey = primaryKey;
if (core.getState("appendTimestamp") == "true") {
saveKey += new Date().toISOString();
saveKey += "-" + new Date().toISOString();
} else {
core.debug("Not appending timestamp because 'append-timestamp' is not set to 'true'.");
}
Expand Down

0 comments on commit 92af2b3

Please sign in to comment.