Avoid unnecessary permissions changes for copy paths (#1152)

In Rust, `fs::copy` automatically preserves permissions (see:
https://doc.rust-lang.org/std/fs/fn.copy.html).

Elsewhere, when copying from the zip archive out to the cache, we can
set permissions during file creation, rather than as a separate call.

Both of these should be slightly more efficient.
This commit is contained in:
Charlie Marsh 2024-01-27 19:11:55 -08:00 committed by GitHub
parent d6795da0ea
commit d243250dec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 120 additions and 34 deletions

View file

@ -353,22 +353,9 @@ fn copy_wheel_files(
continue;
}
// Copy the file.
// Copy the file, which will also set its permissions.
fs::copy(path, &out_path)?;
#[cfg(unix)]
{
use std::fs::Permissions;
use std::os::unix::fs::PermissionsExt;
if let Ok(metadata) = entry.metadata() {
fs::set_permissions(
&out_path,
Permissions::from_mode(metadata.permissions().mode()),
)?;
}
}
count += 1;
}