mirror of
https://git.proxmox.com/git/pathpatterns
synced 2025-08-15 15:29:43 +00:00
minor cleanups
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
parent
4f065f7e73
commit
17ac15fc3e
@ -43,7 +43,7 @@ pub struct FileModeRequired;
|
|||||||
|
|
||||||
impl std::fmt::Display for FileModeRequired {
|
impl std::fmt::Display for FileModeRequired {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "File mode is required for matching")
|
f.write_str("file mode is required for matching")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ where
|
|||||||
impl GetFileMode for Option<u32> {
|
impl GetFileMode for Option<u32> {
|
||||||
type Error = FileModeRequired;
|
type Error = FileModeRequired;
|
||||||
fn get(self) -> Result<u32, Self::Error> {
|
fn get(self) -> Result<u32, Self::Error> {
|
||||||
self.ok_or(FileModeRequired {})
|
self.ok_or(FileModeRequired)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -346,10 +346,7 @@ impl MatchEntry {
|
|||||||
|
|
||||||
pub fn needs_file_mode(&self) -> bool {
|
pub fn needs_file_mode(&self) -> bool {
|
||||||
let flags = (self.flags & MatchFlag::ANY_FILE_TYPE).bits();
|
let flags = (self.flags & MatchFlag::ANY_FILE_TYPE).bits();
|
||||||
if flags != 0 && flags != MatchFlag::ANY_FILE_TYPE.bits() {
|
flags != 0 && flags != MatchFlag::ANY_FILE_TYPE.bits()
|
||||||
return true;
|
|
||||||
}
|
|
||||||
false
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -629,7 +626,7 @@ fn matches_path() {
|
|||||||
];
|
];
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
matchlist.matches("ahsjdj", || Err(FileModeRequired {})),
|
matchlist.matches("ahsjdj", || Err(FileModeRequired)),
|
||||||
Ok(Some(MatchType::Exclude))
|
Ok(Some(MatchType::Exclude))
|
||||||
);
|
);
|
||||||
let mut test = 1;
|
let mut test = 1;
|
||||||
@ -654,11 +651,11 @@ fn matches_path() {
|
|||||||
assert_eq!(result, Ok(Some(MatchType::Exclude)));
|
assert_eq!(result, Ok(Some(MatchType::Exclude)));
|
||||||
assert_eq!(test, 2);
|
assert_eq!(test, 2);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
matchlist.matches("ahsjdj", || Err(FileModeRequired {})),
|
matchlist.matches("ahsjdj", || Err(FileModeRequired)),
|
||||||
Err(FileModeRequired {})
|
Err(FileModeRequired)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
matchlist.matches("bhshdf", || Err(FileModeRequired {})),
|
matchlist.matches("bhshdf", || Err(FileModeRequired)),
|
||||||
Ok(Some(MatchType::Exclude))
|
Ok(Some(MatchType::Exclude))
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -672,12 +669,12 @@ fn matches_path() {
|
|||||||
.flags(MatchFlag::MATCH_DIRECTORIES),
|
.flags(MatchFlag::MATCH_DIRECTORIES),
|
||||||
];
|
];
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
matchlist.matches("ahsjdj", || Err(FileModeRequired {})),
|
matchlist.matches("ahsjdj", || Err(FileModeRequired)),
|
||||||
Err(FileModeRequired {})
|
Err(FileModeRequired)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
matchlist.matches("bhshdf", || Err(FileModeRequired {})),
|
matchlist.matches("bhshdf", || Err(FileModeRequired)),
|
||||||
Err(FileModeRequired {})
|
Err(FileModeRequired)
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
matchlist.matches("ahsjdj", || Ok::<u32, FileModeRequired>(libc::S_IFDIR)),
|
matchlist.matches("ahsjdj", || Ok::<u32, FileModeRequired>(libc::S_IFDIR)),
|
||||||
|
Loading…
Reference in New Issue
Block a user