[rust] Check driver in cache before uncompressing (fix
@@ -88,7 +88,9 @@ pub fn untargz(file: File, target: PathBuf) -> Result<(), Box<dyn Error>> {
let parent_path = target
.parent()
.ok_or(format!("Error getting parent of {:?}", file))?;
+ if !target.exists() {
archive.unpack(parent_path)?;
+ }
Ok(())
}
@@ -98,6 +100,9 @@ pub fn unzip(file: File, target: PathBuf) -> Result<(), Box<dyn Error>> {
for i in 0..archive.len() {
let mut file = archive.by_index(i)?;
+ if target.exists() {
+ continue;
+ }
let target_file_name = target.file_name().unwrap().to_str().unwrap();
if target_file_name == file.name() {
log::debug!(
@@ -108,6 +113,7 @@ pub fn unzip(file: File, target: PathBuf) -> Result<(), Box<dyn Error>> {
if let Some(p) = target.parent() {
create_path_if_not_exists(p);
}
+ if !target.exists() {
let mut outfile = File::create(&target)?;
// Set permissions in Unix-like systems
@@ -119,6 +125,7 @@ pub fn unzip(file: File, target: PathBuf) -> Result<(), Box<dyn Error>> {
}
io::copy(&mut file, &mut outfile)?;
+ }
break;
}
}
