[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.
This commit is contained in:
Robbert van der Helm
2022-06-25 13:29:23 +02:00
parent 687bee34d5
commit 414fd97216
3 changed files with 29 additions and 4 deletions
+6 -1
View File
@@ -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 presets due to some mutually recursive function calls that weren't being
handled as such. 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 - 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 Windows VST3 bundle. For the record, you really, really, _really_ shouldn't be
doing this. doing this.
+22 -2
View File
@@ -547,7 +547,17 @@ impl SearchIndex {
Ok(Err(path)) Ok(Err(path))
} }
}) })
.collect::<Result<_>>()?; // 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<Result<Vst2Plugin, PathBuf>>| 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 // 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 // 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)) Ok(Err(module_path))
} }
}) })
.collect::<Result<_>>()?; // 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<Result<Vst3Module, PathBuf>>| match result {
Ok(result) => Some(result),
Err(err) => {
eprintln!("WARNING: Skipping file during scan: {err:#}\n");
None
}
})
.collect();
let mut plugins: Vec<Plugin> = Vec::new(); let mut plugins: Vec<Plugin> = Vec::new();
let mut skipped_files: Vec<PathBuf> = Vec::new(); let mut skipped_files: Vec<PathBuf> = Vec::new();
+1 -1
View File
@@ -36,7 +36,7 @@ pub struct Pe32Info {
pub fn parse_pe32_binary<P: AsRef<Path>>(binary: P) -> Result<Pe32Info> { pub fn parse_pe32_binary<P: AsRef<Path>>(binary: P) -> Result<Pe32Info> {
parse_pe32_goblin(&binary).or_else(|err| { parse_pe32_goblin(&binary).or_else(|err| {
parse_pe32_winedump(binary) 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}"))
}) })
} }