From 1304a2ec8d64445507420173d3e394895ef4885e Mon Sep 17 00:00:00 2001 From: Arpad Borsos Date: Mon, 28 Sep 2020 12:00:58 +0200 Subject: [PATCH] add ability to version caches --- src/common.ts | 16 ++++++++++------ src/save.ts | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/common.ts b/src/common.ts index 1fb93f8..3270570 100644 --- a/src/common.ts +++ b/src/common.ts @@ -45,18 +45,22 @@ export async function getCaches(): Promise { if (targetKey) { targetKey = `${targetKey}-`; } + + const registryIndex = `v0-registry-index`; + const registryCache = `v0-registry-cache`; + const target = `v0-target-${targetKey}${rustKey}`; return { index: { name: "Registry Index", path: paths.index, - key: "registry-index-XXX", - restoreKeys: ["registry-index"], + key: `${registryIndex}-`, + restoreKeys: [registryIndex], }, cache: { name: "Registry Cache", path: paths.cache, - key: `registry-cache-${lockHash}`, - restoreKeys: ["registry-cache"], + key: `${registryCache}-${lockHash}`, + restoreKeys: [registryCache], }, git: { name: "Git Dependencies", @@ -66,8 +70,8 @@ export async function getCaches(): Promise { target: { name: "Target", path: paths.target, - key: `target-${targetKey}${rustKey}-${lockHash}`, - restoreKeys: [`target-${targetKey}${rustKey}`], + key: `${target}-${lockHash}`, + restoreKeys: [target], }, }; } diff --git a/src/save.ts b/src/save.ts index 93aada8..094415b 100644 --- a/src/save.ts +++ b/src/save.ts @@ -19,7 +19,7 @@ async function run() { if (registryName) { // save the index based on its revision const indexRef = await getIndexRef(registryName); - caches.index.key = `registry-index-${indexRef}`; + caches.index.key += indexRef; await io.rmRF(path.join(paths.index, registryName, ".cache")); await pruneRegistryCache(registryName, packages);