add wrapper struct with case-folding get impl

This commit is contained in:
llama 2025-11-18 21:20:10 +08:00
parent dac26ce671
commit aca5b8e32a
No known key found for this signature in database
GPG key ID: 0B7543854B9413C3

View file

@ -18,6 +18,20 @@ use crate::prelude::*;
pub mod changetracker;
pub struct Checksums(HashMap<String, Sha1Hash>);
impl Checksums {
// case-fold filenames when checking files to be imported
// to account for case-insensitive filesystems
pub fn get(&self, key: impl AsRef<str>) -> Option<&Sha1Hash> {
self.0.get(key.as_ref().to_lowercase().as_str())
}
pub fn contains_key(&self, key: impl AsRef<str>) -> bool {
self.get(key).is_some()
}
}
#[derive(Debug, PartialEq, Eq)]
pub struct MediaEntry {
pub fname: String,