From 09117ad0a0ad84acef0337015dc2bb410f95d2a1 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Thu, 10 Aug 2023 18:28:59 +1000 Subject: [PATCH] Fix hashing of parsed `Cargo.toml` The values for the dependencies could be strings intead of objects, so add a `try` block to take care of that. Also set `dep.path` to `""` if the dependency contains a key `path` to make sure that the cache isn't invalidated due to change in workspace. Signed-off-by: Jiahao XU --- dist/restore/index.js | 12 ++++++++++-- dist/save/index.js | 12 ++++++++++-- src/config.ts | 11 +++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/dist/restore/index.js b/dist/restore/index.js index 51219fe..0cb1e52 100644 --- a/dist/restore/index.js +++ b/dist/restore/index.js @@ -67021,8 +67021,16 @@ class CacheConfig { const deps = parsed[section_name]; for (const key of Object.keys(deps)) { const dep = deps[key]; - if ("path" in dep) { - dep.version = "0.0.0"; + try { + if ("path" in dep) { + dep.version = "0.0.0"; + dep.path = ""; + } + } + catch (_e) { + // Not an object, probably a string (version), + // continue. + continue; } } } diff --git a/dist/save/index.js b/dist/save/index.js index a11263d..ab19d33 100644 --- a/dist/save/index.js +++ b/dist/save/index.js @@ -67021,8 +67021,16 @@ class CacheConfig { const deps = parsed[section_name]; for (const key of Object.keys(deps)) { const dep = deps[key]; - if ("path" in dep) { - dep.version = "0.0.0"; + try { + if ("path" in dep) { + dep.version = "0.0.0"; + dep.path = ""; + } + } + catch (_e) { + // Not an object, probably a string (version), + // continue. + continue; } } } diff --git a/src/config.ts b/src/config.ts index 07b2eaf..b4023f7 100644 --- a/src/config.ts +++ b/src/config.ts @@ -166,8 +166,15 @@ export class CacheConfig { for (const key of Object.keys(deps)) { const dep = deps[key]; - if ("path" in dep) { - dep.version = "0.0.0"; + try { + if ("path" in dep) { + dep.version = "0.0.0"; + dep.path = ""; + } + } catch (_e) { + // Not an object, probably a string (version), + // continue. + continue; } } }