Skip to content

Commit

Permalink
Fix hashing of parsed Cargo.toml (#160)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
NobodyXu authored Aug 12, 2023
1 parent 4e0f4b1 commit c0e052c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
12 changes: 10 additions & 2 deletions dist/restore/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions dist/save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down
11 changes: 9 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
Expand Down

0 comments on commit c0e052c

Please sign in to comment.