translate: skip known non-shader asset packs in precompile
(cherry picked from commit 8e3a1f4cf99f06cb3425eb82c42026458cbcfed5)
This commit is contained in:
1 parent
761de52baf
commit
5732b3df3c
1 file changed
+27
-1
@@ -393,6 +393,29 @@ pub fn run(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Skip known texture, media, and metadata packs that cannot contain shader containers.
|
||||
fn may_hold_shaders(path: &std::path::Path) -> bool {
|
||||
match path.extension().and_then(|e| e.to_str()) {
|
||||
None => true,
|
||||
Some(ext) => !matches!(
|
||||
ext.to_ascii_lowercase().as_str(),
|
||||
"ttpf"
|
||||
| "png"
|
||||
| "jpg"
|
||||
| "jpeg"
|
||||
| "dds"
|
||||
| "bik"
|
||||
| "bk2"
|
||||
| "wem"
|
||||
| "bnk"
|
||||
| "xml"
|
||||
| "pri"
|
||||
| "config"
|
||||
| "alignmentchunk"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
/// Every shader found into the cache runs translate from.
|
||||
pub fn precompile(paths: Vec<PathBuf>, jobs: Option<usize>) -> Result<()> {
|
||||
let cfg = victory_core::Config::load()?;
|
||||
@@ -406,7 +429,10 @@ pub fn precompile(paths: Vec<PathBuf>, jobs: Option<usize>) -> Result<()> {
|
||||
let failed = Mutex::new(BTreeMap::<String, (usize, String)>::new());
|
||||
for root in &paths {
|
||||
for entry in walkdir::WalkDir::new(root).into_iter().filter_map(Result::ok) {
|
||||
if !entry.file_type().is_file() || entry.metadata().map_or(0, |m| m.len()) > MAX_FILE {
|
||||
if !entry.file_type().is_file()
|
||||
|| !may_hold_shaders(entry.path())
|
||||
|| entry.metadata().map_or(0, |m| m.len()) > MAX_FILE
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let Ok(data) = std::fs::read(entry.path()) else {
|
||||
|
||||
Reference in new issue
Block a user