Skip to content

Commit

Permalink
if there is anything wrong with the cached constant_resolver, discard it
Browse files Browse the repository at this point in the history
  • Loading branch information
perryqh committed Aug 1, 2024
1 parent 51c4ba7 commit a630b23
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

[package]
name = "pks"
version = "0.2.18"
version = "0.2.19"
edition = "2021"
description = "Welcome! Please see https://github.com/rubyatscale/pks for more information!"
license = "MIT"
Expand Down
14 changes: 8 additions & 6 deletions src/packs/parsing/ruby/zeitwerk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,14 +186,16 @@ struct ConstantResolverCache {
fn get_constant_resolver_cache(cache_dir: &Path) -> ConstantResolverCache {
let path = cache_dir.join("constant_resolver.json");
if path.exists() {
let file = std::fs::File::open(path).unwrap();
let reader = std::io::BufReader::new(file);
serde_json::from_reader(reader).unwrap()
} else {
ConstantResolverCache {
file_definition_map: HashMap::new(),
if let Ok(file) = std::fs::File::open(path) {
let reader = std::io::BufReader::new(file);
if let Ok(cache) = serde_json::from_reader(reader) {
cache
}
}
}
ConstantResolverCache {
file_definition_map: HashMap::new(),
}
}

fn cache_constant_definitions(
Expand Down

0 comments on commit a630b23

Please sign in to comment.