fix issue #1260: give a warning if an error occurs on language files load

This commit is contained in:
Enrico Marconi 2021-08-03 21:09:05 +00:00 committed by Marcel
parent e6ef678c28
commit cae8005a18

View File

@ -113,17 +113,25 @@ impl common_assets::Compound for Language {
// Walk through files in the folder, collecting localization fragment to merge // Walk through files in the folder, collecting localization fragment to merge
// inside the asked_localization // inside the asked_localization
let mut fragments = HashMap::new(); let mut fragments = HashMap::new();
for fragment_asset in cache for id in cache
.load_dir::<RawFragment<String>>(asset_key, true)? .load_dir::<RawFragment<String>>(asset_key, true)?
.iter() .ids()
{ {
let id = fragment_asset.id(); // Don't try to load manifests
// don't try to load ._manifest files if id.ends_with(&[".", LANG_MANIFEST_FILE].concat()) {
if id.ends_with("._manifest") {
continue; continue;
} }
let read = fragment_asset.read();
fragments.insert(PathBuf::from(id), read.clone()); match cache.load(id) {
Ok(handle) => {
let fragment: &RawFragment<String> = &*handle.read();
fragments.insert(PathBuf::from(id), fragment.clone());
},
Err(e) => {
warn!("Unable to load asset {}, error={:?}", id, e);
},
}
} }
Ok(Language::from(RawLanguage { Ok(Language::from(RawLanguage {