Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/src/command/chmod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ const fn default_permission_mode(kind: DataKind) -> u16 {
match kind {
DataKind::Directory => 0o755,
DataKind::File | DataKind::SymbolicLink | DataKind::HardLink => 0o644,
DataKind::Reserved(_) | DataKind::Private(_) => 0,
}
}

Expand Down
3 changes: 3 additions & 0 deletions cli/src/command/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ fn compare_entry<T: AsRef<[u8]>>(
DataKind::HardLink => {
println!("{}", DiffKind::TypeMismatch.display(path_str));
}
_ => {
println!("{}", DiffKind::TypeMismatch.display(path_str));
}
}
Ok(())
}
32 changes: 30 additions & 2 deletions cli/src/command/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ enum EntryType {
Directory(String),
SymbolicLink(String, String),
HardLink(String, String),
Unknown(String, DataKind),
}

impl EntryType {
Expand All @@ -297,7 +298,8 @@ impl EntryType {
EntryType::File(name)
| EntryType::Directory(name)
| EntryType::SymbolicLink(name, _)
| EntryType::HardLink(name, _) => name,
| EntryType::HardLink(name, _)
| EntryType::Unknown(name, _) => name,
}
}

Expand All @@ -322,6 +324,7 @@ impl Display for EntryTypeBsdLongStyleDisplay<'_> {
EntryType::HardLink(name, link_to) => {
write!(f, "{name} link to {link_to}")
}
EntryType::Unknown(name, _) => Display::fmt(&name, f),
}
}
}
Expand Down Expand Up @@ -451,6 +454,7 @@ impl TableRow {
),
DataKind::Directory => EntryType::Directory(entry.name().to_string()),
DataKind::File => EntryType::File(entry.name().to_string()),
kind => EntryType::Unknown(entry.name().to_string(), kind),
},
// Only collect xattrs if needed
xattrs: if collect.xattrs {
Expand Down Expand Up @@ -1081,7 +1085,7 @@ fn detailed_format_name(entry: EntryType, options: &ListOptions) -> String {
EntryType::SymbolicLink(name, link_to) if options.classify => {
format!("{name}@ -> {link_to}")
}
EntryType::File(path) | EntryType::Directory(path) => path,
EntryType::File(path) | EntryType::Directory(path) | EntryType::Unknown(path, _) => path,
EntryType::SymbolicLink(path, link_to) | EntryType::HardLink(path, link_to) => {
format!("{path} -> {link_to}")
}
Expand Down Expand Up @@ -1200,6 +1204,7 @@ fn kind_paint(kind: &EntryType) -> impl Display + 'static {
EntryType::File(_) | EntryType::HardLink(_, _) => STYLE_HYPHEN.paint('.'),
EntryType::Directory(_) => STYLE_DIR.paint('d'),
EntryType::SymbolicLink(_, _) => STYLE_LINK.paint('l'),
EntryType::Unknown(_, _) => STYLE_HYPHEN.paint('?'),
}
}

Expand Down Expand Up @@ -1239,6 +1244,7 @@ const fn kind_char(kind: &EntryType) -> char {
EntryType::File(_) | EntryType::HardLink(_, _) => '-',
EntryType::Directory(_) => 'd',
EntryType::SymbolicLink(_, _) => 'l',
EntryType::Unknown(_, _) => '?',
}
}

Expand Down Expand Up @@ -1272,6 +1278,7 @@ impl PermissionDisplay {
EntryType::HardLink(_, _) => 'h',
EntryType::Directory(_) => 'd',
EntryType::SymbolicLink(_, _) => 'l',
EntryType::Unknown(_, _) => '?',
},
permission,
indicator: if has_acl { '+' } else { ' ' },
Expand Down Expand Up @@ -1526,6 +1533,7 @@ fn tree_entries_to(
EntryType::Directory(name) => (name.as_str(), DataKind::Directory),
EntryType::SymbolicLink(name, _) => (name.as_str(), DataKind::SymbolicLink),
EntryType::HardLink(name, _) => (name.as_str(), DataKind::HardLink),
EntryType::Unknown(name, kind) => (name.as_str(), *kind),
});
let map = build_tree_map(entries);
let tree = build_term_tree(&map, Cow::Borrowed(""), None, DataKind::Directory, options);
Expand Down Expand Up @@ -1648,6 +1656,26 @@ mod tests {
);
}

#[test]
fn unknown_entry_type_does_not_render_as_file() {
let entry_type = EntryType::Unknown("private-entry".into(), DataKind::Private(128));

assert_eq!(entry_type.name(), "private-entry");
assert_eq!(
entry_type.bsd_long_style_display().to_string(),
"private-entry"
);
assert_eq!(kind_char(&entry_type), '?');
assert_eq!(
PermissionDisplay::new(&entry_type, 0o644, false, false).to_string(),
"?rw-r--r-- "
);
assert_eq!(
PermissionDisplay::bsdtar(&entry_type, 0o644, false).to_string(),
"?rw-r--r-- "
);
}

#[test]
fn i64_max_seconds_exceed_jiff_window() {
assert!(unix_timestamp_to_local_opt(&TimeZone::UTC, i64::MAX, 0).is_none());
Expand Down
14 changes: 7 additions & 7 deletions lib/src/entry/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ impl EntryHeader {
let mut data = Vec::with_capacity(6 + name.len());
data.push(self.major);
data.push(self.minor);
data.push(self.data_kind as u8);
data.push(self.compression as u8);
data.push(self.encryption as u8);
data.push(self.cipher_mode as u8);
data.push(self.data_kind.to_byte());
data.push(self.compression.to_byte());
data.push(self.encryption.to_byte());
data.push(self.cipher_mode.to_byte());
data.extend_from_slice(name);
data
}
Expand Down Expand Up @@ -272,9 +272,9 @@ impl SolidHeader {
[
self.major,
self.minor,
self.compression as u8,
self.encryption as u8,
self.cipher_mode as u8,
self.compression.to_byte(),
self.encryption.to_byte(),
self.cipher_mode.to_byte(),
]
}

Expand Down
Loading
Loading