change visibility of persistency::DataStore::extract_hash
This commit is contained in:
parent
89b2b480ce
commit
92b053769a
|
@ -199,20 +199,20 @@ impl DataStore {
|
||||||
self.textures.iter()
|
self.textures.iter()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn extract_hash(filename: &std::ffi::OsStr) -> Option<Sha256> {
|
|
||||||
// directly return None for invalidly encoded file names
|
|
||||||
let str_name = filename.to_str()?;
|
|
||||||
let hash = Sha256::from_hex(str_name)?;
|
|
||||||
|
|
||||||
// check back to ignore names with lowercase letters
|
|
||||||
if hash.as_hex_string() == str_name {
|
|
||||||
Some(hash)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn garbage_collect(&mut self) -> io::Result<()> {
|
pub fn garbage_collect(&mut self) -> io::Result<()> {
|
||||||
|
fn extract_hash(filename: &std::ffi::OsStr) -> Option<Sha256> {
|
||||||
|
// directly return None for invalidly encoded file names
|
||||||
|
let str_name = filename.to_str()?;
|
||||||
|
let hash = Sha256::from_hex(str_name)?;
|
||||||
|
|
||||||
|
// check back to ignore names with lowercase letters
|
||||||
|
if hash.as_hex_string() == str_name {
|
||||||
|
Some(hash)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let texture_dir = std::fs::read_dir(self.texture_base_path())?;
|
let texture_dir = std::fs::read_dir(self.texture_base_path())?;
|
||||||
|
|
||||||
let mut hashs_on_disk = HashSet::new();
|
let mut hashs_on_disk = HashSet::new();
|
||||||
|
@ -222,7 +222,7 @@ impl DataStore {
|
||||||
Some(name) => name,
|
Some(name) => name,
|
||||||
None => continue,
|
None => continue,
|
||||||
};
|
};
|
||||||
match Self::extract_hash(filename) {
|
match extract_hash(filename) {
|
||||||
Some(hash) => {
|
Some(hash) => {
|
||||||
hashs_on_disk.insert(hash);
|
hashs_on_disk.insert(hash);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue