mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-03 05:03:46 +00:00
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:
parent
d6795da0ea
commit
d243250dec
4 changed files with 120 additions and 34 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue