From c0e052c18c9b4a329d1bf4b7bc6d1ce0eba7bbee Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Sat, 12 Aug 2023 20:34:30 +1000 Subject: [PATCH] Fix hashing of parsed `Cargo.toml` (#160) 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 64298cf..c46f99e 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 a6d9c5d..f939359 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 598ab0b..cd73f6c 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; } } }