mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-20 15:53:59 +08:00
Encode cache keys
* remove restriction on commas in keys * avoid 404 during save when characters like slashes are used in keys fixes #53
This commit is contained in:
parent
f66a56e59e
commit
cda609ee82
1 changed files with 8 additions and 11 deletions
|
@ -17,12 +17,16 @@ async function run() {
|
||||||
);
|
);
|
||||||
core.debug(`Cache Path: ${cachePath}`);
|
core.debug(`Cache Path: ${cachePath}`);
|
||||||
|
|
||||||
const primaryKey = core.getInput(Inputs.Key, { required: true });
|
const keys = [
|
||||||
|
core.getInput(Inputs.Key, { required: true }),
|
||||||
|
...core
|
||||||
|
.getInput(Inputs.RestoreKeys)
|
||||||
|
.split(/\s*\n\s*/)
|
||||||
|
.filter(x => x)
|
||||||
|
].map(key => encodeURIComponent(key).replace(/%/g, " "));
|
||||||
|
const primaryKey = keys[0];
|
||||||
core.saveState(State.CacheKey, primaryKey);
|
core.saveState(State.CacheKey, primaryKey);
|
||||||
|
|
||||||
const restoreKeys = core.getInput(Inputs.RestoreKeys).split("\n");
|
|
||||||
const keys = [primaryKey, ...restoreKeys];
|
|
||||||
|
|
||||||
core.debug("Resolved Keys:");
|
core.debug("Resolved Keys:");
|
||||||
core.debug(JSON.stringify(keys));
|
core.debug(JSON.stringify(keys));
|
||||||
|
|
||||||
|
@ -39,13 +43,6 @@ async function run() {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const regex = /^[^,]*$/;
|
|
||||||
if (!regex.test(key)) {
|
|
||||||
core.setFailed(
|
|
||||||
`Key Validation Error: ${key} cannot contain commas.`
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue