change visibility of persistency::DataStore::extract_hash

This commit is contained in:
CodeSteak 2019-05-09 20:14:34 +02:00
parent 89b2b480ce
commit 92b053769a

View File

@ -199,7 +199,8 @@ impl DataStore {
self.textures.iter() self.textures.iter()
} }
pub fn extract_hash(filename: &std::ffi::OsStr) -> Option<Sha256> { 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 // directly return None for invalidly encoded file names
let str_name = filename.to_str()?; let str_name = filename.to_str()?;
let hash = Sha256::from_hex(str_name)?; let hash = Sha256::from_hex(str_name)?;
@ -212,7 +213,6 @@ impl DataStore {
} }
} }
pub fn garbage_collect(&mut self) -> io::Result<()> {
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);
} }