mirror of
https://github.com/ankitects/anki.git
synced 2025-12-16 00:00:59 -05:00
add wrapper struct with case-folding get impl
This commit is contained in:
parent
dac26ce671
commit
aca5b8e32a
1 changed files with 14 additions and 0 deletions
|
|
@ -18,6 +18,20 @@ use crate::prelude::*;
|
||||||
|
|
||||||
pub mod changetracker;
|
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)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct MediaEntry {
|
pub struct MediaEntry {
|
||||||
pub fname: String,
|
pub fname: String,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue