zip: go back to saying we're unix, we just forgot to include unix permissions in the external file attributes
This commit is contained in:
parent
527f184944
commit
f10ee6aa2a
23
src/zip.rs
23
src/zip.rs
|
@ -136,24 +136,13 @@ impl UploadedFile {
|
|||
|
||||
fn central_directory_header(&self, local_header_offset: usize, hash: u32) -> Vec<u8> {
|
||||
let mut header = vec![
|
||||
// Central directory file header signature
|
||||
0x50, 0x4b, 0x01, 0x02,
|
||||
// Made by a "DOS" system supporting version 4.5 - if we
|
||||
// say it's made by a Unix system, then unzip will expect
|
||||
// it to have embedded Unix permission information, and
|
||||
// will set all the files to mode 000 when that's not
|
||||
// present :/
|
||||
45, 0,
|
||||
0x50, 0x4b, 0x01, 0x02, // Central directory file header signature
|
||||
45, 3, // Made by a Unix system supporting version 4.5
|
||||
];
|
||||
header.append(&mut self.shared_header_fields(Some(hash)));
|
||||
header.append(&mut vec![
|
||||
0, 0, // File comment length: 0
|
||||
0, 0, // Disk number where file starts: 0
|
||||
0, 0, // Internal file attributes: nothing
|
||||
0, 0, 0, 0, // External file attributes: nothing
|
||||
0xff, 0xff, 0xff,
|
||||
0xff, // Relative offset of local file header: placeholder, see ZIP64 data
|
||||
]);
|
||||
append_0(&mut header, 8); // Comment length, disk number, internal attributes, DOS external attributes
|
||||
append_value(&mut header, 0o100644, 2); // Unix external file attributes: -rw-r--r--
|
||||
append_ff(&mut header, 4); // Relative offset of local file header: placeholder, see ZIP64 data
|
||||
header.append(&mut self.name.clone().into_bytes());
|
||||
header.append(&mut self.extra_field(local_header_offset));
|
||||
header
|
||||
|
@ -179,7 +168,7 @@ fn end_of_central_directory(files: &[UploadedFile]) -> Vec<u8> {
|
|||
];
|
||||
append_0(&mut eocd, 7); // pad out the rest of the size field
|
||||
eocd.append(&mut vec![
|
||||
45, 0, // Made by a "DOS" system supporting version 4.5, see above
|
||||
45, 3, // Made by a Unix system supporting version 4.5
|
||||
45, 0, // Minimum version 4.5 to extract
|
||||
]);
|
||||
append_0(&mut eocd, 8); // Two 4-byte disk numbers, both 0
|
||||
|
|
Loading…
Reference in a new issue