From 414fd972161149007e1366d4ab148b5fd3b8fa3d Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sat, 25 Jun 2022 13:29:23 +0200 Subject: [PATCH] [yabridgectl] Make scanning errors non-fatal This should never occur, but somehow people have text files with .dll or .vst3 extensions in their plugin directories. This resolves #185. --- CHANGELOG.md | 7 ++++++- tools/yabridgectl/src/files.rs | 24 ++++++++++++++++++++++-- tools/yabridgectl/src/symbols.rs | 2 +- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bb26c01..9c0c12c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,8 +19,13 @@ Versioning](https://semver.org/spec/v2.0.0.html). presets due to some mutually recursive function calls that weren't being handled as such. -### yabridge +### yabridgectl +- Parsing errors for plugin binaries are now non-fatal. This could happen when + you have a text file with a `.dll` or `.vst3` extension in your plugin search + locations. This normally would never happen, but it can happen if you manually + extract a .zip file containing Windows plugins to those directories that was + created on macOS. Don't ask me how or why. - Don't panic when someone `yabridgectl add`'ed part of the contents of a Windows VST3 bundle. For the record, you really, really, _really_ shouldn't be doing this. diff --git a/tools/yabridgectl/src/files.rs b/tools/yabridgectl/src/files.rs index 9bd2471d..511d335a 100644 --- a/tools/yabridgectl/src/files.rs +++ b/tools/yabridgectl/src/files.rs @@ -547,7 +547,17 @@ impl SearchIndex { Ok(Err(path)) } }) - .collect::>()?; + // Make parsing failures non-fatal. People somehow extract these `__MACOSX` and other + // junk files from zip files containing Windows VST2/VST3 plugins created on macOS to + // their plugin directories (how does such a thing even happen in the first place?) + .filter_map(|result: Result>| match result { + Ok(result) => Some(result), + Err(err) => { + eprintln!("WARNING: Skipping file during scan: {err:#}\n"); + None + } + }) + .collect(); // We need to do the same thing with VST3 plugins. The added difficulty here is that we have // to figure out of the `.vst3` file is a legacy standalone VST3 module, or part of a VST @@ -629,7 +639,17 @@ impl SearchIndex { Ok(Err(module_path)) } }) - .collect::>()?; + // Make parsing failures non-fatal. People somehow extract these `__MACOSX` and other + // junk files from zip files containing Windows VST2/VST3 plugins created on macOS to + // their plugin directories (how does such a thing even happen in the first place?) + .filter_map(|result: Result>| match result { + Ok(result) => Some(result), + Err(err) => { + eprintln!("WARNING: Skipping file during scan: {err:#}\n"); + None + } + }) + .collect(); let mut plugins: Vec = Vec::new(); let mut skipped_files: Vec = Vec::new(); diff --git a/tools/yabridgectl/src/symbols.rs b/tools/yabridgectl/src/symbols.rs index d11c459d..d135f1bc 100644 --- a/tools/yabridgectl/src/symbols.rs +++ b/tools/yabridgectl/src/symbols.rs @@ -36,7 +36,7 @@ pub struct Pe32Info { pub fn parse_pe32_binary>(binary: P) -> Result { parse_pe32_goblin(&binary).or_else(|err| { parse_pe32_winedump(binary) - .with_context(|| format!("Parsing with goblin also failed: {err}")) + .with_context(|| format!("Failed to parse with both winedump and goblin: {err}")) }) }