Skip to content

Commit b9a71a4

Browse files
committed
fix: always write slash paths to RECORD file
Signed-off-by: Frost Ming <[email protected]>
1 parent 3cb7232 commit b9a71a4

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

crates/uv-install-wheel/src/wheel.rs

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ pub(crate) fn write_file_recorded(
604604
let hash = Sha256::new().chain_update(content.as_ref()).finalize();
605605
let encoded_hash = format!("sha256={}", BASE64URL_NOPAD.encode(&hash));
606606
record.push(RecordEntry {
607-
path: relative_path.display().to_string(),
607+
path: relative_path.portable_display().to_string(),
608608
hash: Some(encoded_hash),
609609
size: Some(content.as_ref().len() as u64),
610610
});
@@ -741,7 +741,8 @@ mod test {
741741
use crate::Error;
742742

743743
use super::{
744-
get_script_executable, parse_email_message_file, parse_wheel_file, read_record_file, Script,
744+
get_script_executable, parse_email_message_file, parse_wheel_file, read_record_file,
745+
write_installer_metadata, RecordEntry, Script,
745746
};
746747

747748
#[test]
@@ -1016,4 +1017,36 @@ mod test {
10161017

10171018
Ok(())
10181019
}
1020+
1021+
#[test]
1022+
fn test_write_installer_metadata() {
1023+
let temp_dir = assert_fs::TempDir::new().unwrap();
1024+
let site_packages = temp_dir.path();
1025+
let mut record: Vec<RecordEntry> = Vec::new();
1026+
temp_dir
1027+
.child("foo-0.1.0.dist-info")
1028+
.create_dir_all()
1029+
.unwrap();
1030+
write_installer_metadata(
1031+
site_packages,
1032+
"foo-0.1.0",
1033+
true,
1034+
None,
1035+
None,
1036+
Some("uv"),
1037+
&mut record,
1038+
)
1039+
.unwrap();
1040+
let expected = [
1041+
"foo-0.1.0.dist-info/REQUESTED",
1042+
"foo-0.1.0.dist-info/INSTALLER",
1043+
]
1044+
.map(ToString::to_string)
1045+
.to_vec();
1046+
let actual = record
1047+
.into_iter()
1048+
.map(|entry| entry.path)
1049+
.collect::<Vec<String>>();
1050+
assert_eq!(expected, actual);
1051+
}
10191052
}

0 commit comments

Comments
 (0)