From 1bb7de255b6ff4d93d818ca6c3dcd98113f8e5c4 Mon Sep 17 00:00:00 2001 From: Benoit Daloze Date: Sat, 11 Jul 2020 16:02:33 +0200 Subject: [PATCH] Treat error from restoring the cache as a cache miss (#68) * Don't retry or error out on restore cache errors Co-authored-by: Eliza Brock Marcum --- dist/index.js | 12 +++++++++++- index.js | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 0839809..0138e93 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2427,7 +2427,17 @@ async function bundleInstall(platform, engine, version) { console.log(`Cache key: ${key}`) // restore cache & install - const cachedKey = await cache.restoreCache(paths, key, restoreKeys) + let cachedKey = null + try { + cachedKey = await cache.restoreCache(paths, key, restoreKeys) + } catch (error) { + if (error.name === cache.ValidationError.name) { + throw error; + } else { + core.info(`[warning] There was an error restoring the cache ${error.message}`) + } + } + if (cachedKey) { console.log(`Found cache for key: ${cachedKey}`) } diff --git a/index.js b/index.js index 4fbaa81..83e9d11 100644 --- a/index.js +++ b/index.js @@ -241,7 +241,17 @@ async function bundleInstall(platform, engine, version) { console.log(`Cache key: ${key}`) // restore cache & install - const cachedKey = await cache.restoreCache(paths, key, restoreKeys) + let cachedKey = null + try { + cachedKey = await cache.restoreCache(paths, key, restoreKeys) + } catch (error) { + if (error.name === cache.ValidationError.name) { + throw error; + } else { + core.info(`[warning] There was an error restoring the cache ${error.message}`) + } + } + if (cachedKey) { console.log(`Found cache for key: ${cachedKey}`) }