Skip to content

Commit

Permalink
fix: always write slash paths to RECORD file
Browse files Browse the repository at this point in the history
Signed-off-by: Frost Ming <[email protected]>
  • Loading branch information
frostming committed Dec 26, 2024
1 parent 3cb7232 commit b9a71a4
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions crates/uv-install-wheel/src/wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ pub(crate) fn write_file_recorded(
let hash = Sha256::new().chain_update(content.as_ref()).finalize();
let encoded_hash = format!("sha256={}", BASE64URL_NOPAD.encode(&hash));
record.push(RecordEntry {
path: relative_path.display().to_string(),
path: relative_path.portable_display().to_string(),
hash: Some(encoded_hash),
size: Some(content.as_ref().len() as u64),
});
Expand Down Expand Up @@ -741,7 +741,8 @@ mod test {
use crate::Error;

use super::{
get_script_executable, parse_email_message_file, parse_wheel_file, read_record_file, Script,
get_script_executable, parse_email_message_file, parse_wheel_file, read_record_file,
write_installer_metadata, RecordEntry, Script,
};

#[test]
Expand Down Expand Up @@ -1016,4 +1017,36 @@ mod test {

Ok(())
}

#[test]
fn test_write_installer_metadata() {
let temp_dir = assert_fs::TempDir::new().unwrap();
let site_packages = temp_dir.path();
let mut record: Vec<RecordEntry> = Vec::new();
temp_dir
.child("foo-0.1.0.dist-info")
.create_dir_all()
.unwrap();
write_installer_metadata(
site_packages,
"foo-0.1.0",
true,
None,
None,
Some("uv"),
&mut record,
)
.unwrap();
let expected = [
"foo-0.1.0.dist-info/REQUESTED",
"foo-0.1.0.dist-info/INSTALLER",
]
.map(ToString::to_string)
.to_vec();
let actual = record
.into_iter()
.map(|entry| entry.path)
.collect::<Vec<String>>();
assert_eq!(expected, actual);
}
}

0 comments on commit b9a71a4

Please sign in to comment.