File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -1097,24 +1097,25 @@ async fn lookup_package(
1097
1097
let cache_path = global_hexpm_package_release_response_cache ( & name, & version. to_string ( ) ) ;
1098
1098
let release = match release {
1099
1099
Ok ( rel) => {
1100
- // save
1101
- // FIXME: I may not need to wright every time
1102
1100
let _ = fs. write_bytes ( & cache_path, & resp_body) ;
1103
1101
rel
1104
1102
} ,
1105
1103
Err ( _) => {
1106
- // load
1107
1104
let cached_result = fs. read_bytes ( & cache_path)
1108
1105
. map_err ( |err| Error :: FileIo {
1109
1106
action : FileIoAction :: Read ,
1110
1107
kind : FileKind :: File ,
1111
- path : cache_path,
1108
+ path : cache_path. clone ( ) ,
1112
1109
err : Some ( err. to_string ( ) ) ,
1113
1110
} ) ?;
1114
1111
1115
- // FIXME: I crash when the cache is bad
1116
- // author note
1117
- serde_json:: from_slice ( & cached_result) . expect ( "cache bad" )
1112
+ serde_json:: from_slice ( & cached_result)
1113
+ . map_err ( |err| Error :: FileIo {
1114
+ action : FileIoAction :: Read ,
1115
+ kind : FileKind :: File ,
1116
+ path : cache_path,
1117
+ err : Some ( err. to_string ( ) ) ,
1118
+ } ) ?
1118
1119
}
1119
1120
} ;
1120
1121
let build_tools = release
You can’t perform that action at this time.
0 commit comments