Skip to content

Commit be1ab8b

Browse files
authored
if there is anything wrong with the cached constant_resolver, discard it (#5)
1 parent 51c4ba7 commit be1ab8b

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[package]
44
name = "pks"
5-
version = "0.2.18"
5+
version = "0.2.19"
66
edition = "2021"
77
description = "Welcome! Please see https://github.com/rubyatscale/pks for more information!"
88
license = "MIT"

src/packs/parsing/ruby/zeitwerk/mod.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,16 @@ struct ConstantResolverCache {
186186
fn get_constant_resolver_cache(cache_dir: &Path) -> ConstantResolverCache {
187187
let path = cache_dir.join("constant_resolver.json");
188188
if path.exists() {
189-
let file = std::fs::File::open(path).unwrap();
190-
let reader = std::io::BufReader::new(file);
191-
serde_json::from_reader(reader).unwrap()
192-
} else {
193-
ConstantResolverCache {
194-
file_definition_map: HashMap::new(),
189+
if let Ok(file) = std::fs::File::open(path) {
190+
let reader = std::io::BufReader::new(file);
191+
if let Ok(cache) = serde_json::from_reader(reader) {
192+
cache
193+
}
195194
}
196195
}
196+
ConstantResolverCache {
197+
file_definition_map: HashMap::new(),
198+
}
197199
}
198200

199201
fn cache_constant_definitions(

0 commit comments

Comments
 (0)