Merge branch 'umr1352/fix#1260' into 'master'

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

Closes #1260

See merge request veloren/veloren!2724
This commit is contained in:
Marcel 2021-08-03 21:09:06 +00:00
commit b7bd81388c

View File

@ -113,17 +113,25 @@ impl common_assets::Compound for Language {
// Walk through files in the folder, collecting localization fragment to merge
// inside the asked_localization
let mut fragments = HashMap::new();
for fragment_asset in cache
for id in cache
.load_dir::<RawFragment<String>>(asset_key, true)?
.iter()
.ids()
{
let id = fragment_asset.id();
// don't try to load ._manifest files
if id.ends_with("._manifest") {
// Don't try to load manifests
if id.ends_with(&[".", LANG_MANIFEST_FILE].concat()) {
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 {