Skip to content

Commit

Permalink
resolve warning: use of deprecated associated function `zip::read::Zi…
Browse files Browse the repository at this point in the history
…pFile::<'a>::sanitized_name`
  • Loading branch information
tanj authored and David-OConnor committed May 29, 2021
1 parent 95f53e0 commit fe3f0c9
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -405,25 +405,27 @@ pub fn extract_zip(file: &fs::File, out_path: &Path, rename: &Option<(String, St
let mut file = archive.by_index(i).unwrap();
// Change name here instead of after in case we've already installed a non-renamed version.
// (which would be overwritten by this one.)
let file_str2 = file.sanitized_name();
let file_str2 = file.enclosed_name().unwrap();
let file_str = file_str2.to_str().expect("Problem converting path to str");

let extracted_file = if !file_str.contains("dist-info") && !file_str.contains("egg-info") {
match rename {
Some((old, new)) => file
.sanitized_name()
.to_str()
.unwrap()
.to_owned()
.replace(old, new)
.into(),
None => file.sanitized_name(),
Some((old, new)) => PathBuf::from_str(
file.enclosed_name()
.unwrap()
.to_str()
.unwrap()
.to_owned()
.replace(old, new)
.as_str(),
),
None => PathBuf::from_str(file.enclosed_name().unwrap().to_str().unwrap()),
}
} else {
file.sanitized_name()
PathBuf::from_str(file.enclosed_name().unwrap().to_str().unwrap())
};

let outpath = out_path.join(extracted_file);
let outpath = out_path.join(extracted_file.unwrap());

if (&*file.name()).ends_with('/') {
fs::create_dir_all(&outpath).unwrap();
Expand Down

0 comments on commit fe3f0c9

Please sign in to comment.