-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💥 Changed ACL-related chunk specifications
The current specification for `faCe` chunks does not distinguish between no ACL information and an empty ACL. To address this, we will introduce a new `faCl` chunk. The absence of an `faCe` chunk while an `faCl` chunk exists will indicate an empty ACL. To improve data size efficiency, we will remove the platform specifier from the `faCe` chunk and have the `faCl` chunk hold it instead. The new specifications for the body part of each chunk are as follows: `faCl` chunk `<platform specifier>` `faCe` chunk `<flags>:<owner type>:<owner identifier>:<acl type>:<permissions>`
- Loading branch information
Showing
8 changed files
with
362 additions
and
161 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,51 @@ | ||
use crate::chunk::{self, Ace}; | ||
use crate::chunk::{self, Ace, AcePlatform, AceWithPlatform}; | ||
use pna::{prelude::*, NormalEntry, RawChunk}; | ||
use std::collections::HashMap; | ||
use std::io; | ||
|
||
pub(crate) trait NormalEntryExt { | ||
fn acl(&self) -> io::Result<Vec<Ace>>; | ||
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() | ||
.map(|(platform, ace)| { | ||
ace.into_iter().map(move |it| AceWithPlatform { | ||
platform: platform.clone(), | ||
ace: it, | ||
}) | ||
}) | ||
.flatten() | ||
Check warning Code scanning / clippy called map(..).flatten() on Iterator Warning
called map(..).flatten() on Iterator
Check warning Code scanning / clippy called map(..).flatten() on Iterator Warning
called map(..).flatten() on Iterator
|
||
.collect()) | ||
} | ||
} | ||
|
||
impl<T> NormalEntryExt for NormalEntry<T> | ||
where | ||
RawChunk<T>: Chunk, | ||
{ | ||
#[inline] | ||
fn acl(&self) -> io::Result<Vec<Ace>> { | ||
self.extra_chunks() | ||
.iter() | ||
.filter(|c| c.ty() == chunk::faCe) | ||
.map(|c| Ace::try_from(c.data()).map_err(io::Error::other)) | ||
.collect() | ||
fn acl(&self) -> io::Result<HashMap<AcePlatform, Vec<Ace>>> { | ||
let mut acls = HashMap::new(); | ||
let mut platform = AcePlatform::General; | ||
for c in self.extra_chunks().iter() { | ||
match c.ty() { | ||
chunk::faCl => { | ||
platform = AcePlatform::try_from(c.data()).map_err(io::Error::other)? | ||
} | ||
chunk::faCe => { | ||
let ace = AceWithPlatform::try_from(c.data()).map_err(io::Error::other)?; | ||
if ace.platform != platform { | ||
acls.entry(ace.platform) | ||
} else { | ||
acls.entry(platform.clone()) | ||
} | ||
.or_insert_with(Vec::new) | ||
.push(ace.ace); | ||
} | ||
_ => continue, | ||
} | ||
} | ||
Ok(acls) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters