/// Tries to load and parse DB from disk.
///
/// Most errors will be caught, transformed into `None`s and then the cache path will be cleaned up,
/// returning None. The caller is then free to fetch from the web and attempt to cache again.
Tries to load and parse DB from disk.
Most errors will be caught, transformed into `None`s and then the cache path will be cleaned up,
returning None. The caller is then free to fetch from the web and attempt to cache again.
Tries to load and parse DB from disk . Most errors will be caught transformed into ` None ` s and then the cache path will be cleaned up returning None . The caller is then free to fetch from the web and attempt to cache again .
pub fn cache_fetch() -> Option<Db> {
    match cache_fetch_inner() {
        Ok(cached_db) => cached_db,
        // if any error occurs regarding file access or decoding
        // we try to delete the file to reset state for next time
        Err(err) => {
            eprintln!("cache fetch error: {}", err);
            // attempt clean up
            // errors on this are unlikely and are therefore ignored
            if let Err(err) = fs::remove_file(cache_path()) {
                eprintln!("failed to clean up cache file: {}", err);
            }
            None
        }
    }
}
pub fn cache_fetch ( ) -> Option < Db > { match cache_fetch_inner ( ) { Ok ( cached_db ) => cached_db , // if any error occurs regarding file access or decoding // we try to delete the file to reset state for next time Err ( err ) => { eprintln ! ( " " err ) ; // attempt clean up // errors on this are unlikely and are therefore ignored if let Err ( err ) = fs :: remove_file ( cache_path ( ) ) { eprintln ! ( " " err ) ; } None } } }
Tries to load and parse DB from disk.
Tries to load and parse DB from disk .