@@ -2,7 +2,7 @@ use std::collections::HashMap;
22use std:: ffi:: CStr ;
33use std:: fs:: { create_dir_all, File } ;
44use std:: io;
5- use std:: io:: { Read , BufReader } ;
5+ use std:: io:: { BufReader , Read } ;
66use std:: path:: { Path , PathBuf } ;
77
88use anyhow:: { anyhow, Context , Result } ;
@@ -16,7 +16,8 @@ use crate::content_disposition_parser::parse_filename;
1616use crate :: http_failure:: handle_response_fail;
1717use crate :: progress:: new_progress_bar;
1818
19- static BASE_PATH : Lazy < PathBuf > = Lazy :: new ( || crate :: config:: PROJECT_DIRS . cache_dir ( ) . join ( "jdks" ) ) ;
19+ static BASE_PATH : Lazy < PathBuf > =
20+ Lazy :: new ( || crate :: config:: PROJECT_DIRS . cache_dir ( ) . join ( "jdks" ) ) ;
2021static BY_TTY : Lazy < PathBuf > = Lazy :: new ( || std:: env:: temp_dir ( ) . join ( "jpre-by-tty" ) ) ;
2122
2223pub fn get_symlink_location ( ) -> Result < PathBuf > {
@@ -54,11 +55,15 @@ pub fn get_jdk_version(major: u8) -> Option<String> {
5455 debug ! ( "No release file exists in JDK {}" , major) ;
5556 return None ;
5657 }
57- let config = std:: fs:: read_to_string ( release)
58+ let config = std:: fs:: read_to_string ( & release)
5859 . context ( "Failed to read release file" )
5960 . and_then ( |data| {
60- toml:: from_str :: < HashMap < String , String > > ( data. as_str ( ) )
61- . context ( "Failed to parse TOML from release file" )
61+ toml:: from_str :: < HashMap < String , String > > ( data. as_str ( ) ) . with_context ( || {
62+ format ! (
63+ "Failed to parse TOML from release file '{}'" ,
64+ release. display( )
65+ )
66+ } )
6267 } ) ;
6368 match config {
6469 Ok ( map) => map. get ( "JAVA_VERSION" ) . map ( |v| v. clone ( ) ) ,
@@ -191,14 +196,12 @@ fn finish_extract(
191196 . read_dir ( )
192197 . context ( "Failed to read temp dir" ) ?
193198 . map ( |res| res. map ( |e| e. path ( ) ) )
194- . filter ( |r| {
195- match r {
196- Ok ( p) => match p. file_name ( ) {
197- Some ( name) => !name. to_string_lossy ( ) . starts_with ( "." ) ,
198- _ => true ,
199- }
199+ . filter ( |r| match r {
200+ Ok ( p) => match p. file_name ( ) {
201+ Some ( name) => !name. to_string_lossy ( ) . starts_with ( "." ) ,
200202 _ => true ,
201- }
203+ } ,
204+ _ => true ,
202205 } )
203206 . collect :: < Result < Vec < _ > , io:: Error > > ( )
204207 . context ( "Failed to read temp dir entry" ) ?;
@@ -228,7 +231,8 @@ fn unarchive_tar_gz(path: &Path, expected_size: Option<u64>, reader: impl Read +
228231
229232 let static_path = path. to_path_buf ( ) ;
230233 let _ = std:: thread:: spawn ( move || {
231- let gz_decode = libflate:: gzip:: Decoder :: new ( BufReader :: new ( download_bar. wrap_read ( reader) ) ) . unwrap ( ) ;
234+ let gz_decode =
235+ libflate:: gzip:: Decoder :: new ( BufReader :: new ( download_bar. wrap_read ( reader) ) ) . unwrap ( ) ;
232236 let mut archive = tar:: Archive :: new ( BufReader :: new ( writing_bar. wrap_read ( gz_decode) ) ) ;
233237 archive. set_preserve_permissions ( true ) ;
234238 archive. set_overwrite ( true ) ;
0 commit comments