Skip to content

Commit

Permalink
♻️ Inlinize Ace to AceWithPlatform conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Nov 24, 2024
1 parent fe399d9 commit 62b5630
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
13 changes: 10 additions & 3 deletions cli/src/command/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use rayon::prelude::*;
#[cfg(feature = "memmap")]
use std::path::Path;
use std::{
collections::HashMap,
fmt::{Display, Formatter},
io,
time::{Duration, SystemTime, UNIX_EPOCH},
Expand Down Expand Up @@ -98,7 +99,7 @@ struct TableRow {
modified: Option<Duration>,
name: String,
xattrs: Vec<ExtendedAttribute>,
acl: Vec<chunk::AceWithPlatform>,
acl: HashMap<chunk::AcePlatform, Vec<chunk::Ace>>,
privates: Vec<RawChunk>,
}

Expand All @@ -120,7 +121,7 @@ where
) -> Result<Self, Self::Error> {
let header = entry.header();
let metadata = entry.metadata();
let acl = entry.acl_with_platform()?;
let acl = entry.acl()?;
let has_acl = !acl.is_empty();
let has_xattr = !entry.xattrs().is_empty();
Ok(Self {
Expand Down Expand Up @@ -383,7 +384,13 @@ fn detail_list_entries(entries: impl Iterator<Item = TableRow>, options: ListOpt
content.name,
]);
if options.show_acl {
for a in &content.acl {
let acl = content.acl.into_iter().flat_map(|(platform, ace)| {
ace.into_iter().map(move |it| chunk::AceWithPlatform {
platform: Some(platform.clone()),
ace: it,
})
});
for a in acl {
builder.push_record([String::new(), String::new(), a.to_string()]);
acl_rows.push(builder.count_records());
}
Expand Down
12 changes: 0 additions & 12 deletions cli/src/ext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,6 @@ use std::io;

pub(crate) trait NormalEntryExt {
fn acl(&self) -> io::Result<HashMap<AcePlatform, Vec<Ace>>>;
fn acl_with_platform(&self) -> io::Result<Vec<AceWithPlatform>> {
let acl = self.acl()?;
Ok(acl
.into_iter()
.flat_map(|(platform, ace)| {
ace.into_iter().map(move |it| AceWithPlatform {
platform: Some(platform.clone()),
ace: it,
})
})
.collect())
}
}

impl<T> NormalEntryExt for NormalEntry<T>
Expand Down

0 comments on commit 62b5630

Please sign in to comment.