Separate out reserve call

This commit is contained in:
Josh Gross 2019-12-17 13:56:10 -05:00
parent 7f6523f535
commit 436418ea07
2 changed files with 37 additions and 32 deletions

View file

@ -35,6 +35,12 @@ async function run(): Promise<void> {
return;
}
const cacheId = await cacheHttpClient.reserveCache(primaryKey);
if (cacheId < 0) {
core.info(`Unable to reserve cache with key ${primaryKey}, another job may be creating this cache.`);
return;
}
const cachePath = utils.resolvePath(
core.getInput(Inputs.Path, { required: true })
);
@ -77,7 +83,7 @@ async function run(): Promise<void> {
return;
}
await cacheHttpClient.saveCache(primaryKey, archivePath);
await cacheHttpClient.saveCache(cacheId, archivePath);
} catch (error) {
utils.logWarning(error.message);
}