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 <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2023-08-10 18:28:59 +10:00
parent b919e1427f
commit 09117ad0a0
No known key found for this signature in database
GPG Key ID: D7D0DA2A5FE7AF8B
3 changed files with 29 additions and 6 deletions

12
dist/restore/index.js vendored
View File

@ -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;
}
}
}

12
dist/save/index.js vendored
View File

@ -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;
}
}
}

View File

@ -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;
}
}
}