Skip to content

Commit

Permalink
[rust] Set permissions before copying extracted files
Browse files Browse the repository at this point in the history
  • Loading branch information
bonigarcia committed Aug 9, 2023
1 parent fb40ce3 commit b43135b
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions rust/src/files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,6 @@ pub fn unzip(
let target_path = tmp_path.join(path.clone());
create_parent_path_if_not_exists(target_path.as_path())?;
let mut outfile = File::create(&target_path)?;
io::copy(&mut file, &mut outfile)?;
unzipped_files += 1;
log.trace(format!(
"File extracted to {} ({} bytes)",
target_path.display(),
file.size()
));

// Set permissions in Unix-like systems
#[cfg(unix)]
Expand All @@ -187,6 +180,14 @@ pub fn unzip(
fs::set_permissions(&target_path, fs::Permissions::from_mode(mode))?;
}
}

io::copy(&mut file, &mut outfile)?;
unzipped_files += 1;
log.trace(format!(
"File extracted to {} ({} bytes)",
target_path.display(),
file.size()
));
}
}
if unzipped_files == 0 {
Expand Down

0 comments on commit b43135b

Please sign in to comment.