From a282bdc9d16ba1867cd8173160a25d8f78aab64b Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 12 Jun 2022 23:56:39 +0200 Subject: [PATCH] [yabridgectl] Gracefully catch bundle subdir error This could only occur if people go out of their way to do weird things and add the `x86_64-win` directory inside of a VST3 bundle to their plugin locations. But somehow people still manage to do just that..... --- CHANGELOG.md | 8 ++++++++ tools/yabridgectl/src/files.rs | 27 +++++++++++++++------------ 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b7fb8cd7..33b7c5d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### yabridge + +- 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. + ## [4.0.1] - 2022-06-12 ### Added diff --git a/tools/yabridgectl/src/files.rs b/tools/yabridgectl/src/files.rs index 25c2a783..9bd2471d 100644 --- a/tools/yabridgectl/src/files.rs +++ b/tools/yabridgectl/src/files.rs @@ -599,18 +599,21 @@ impl SearchIndex { // The subdirectory should be relative to the bundle, not to the .vst3 // file inside of the bundle. The latter is what we get from the index // function since it only considers regular files and symlinks. - subdirectory.map(|subdirectory| { - subdirectory - // x86_64-win - .parent() - .unwrap() - // Contents - .parent() - .unwrap() - // foo.vst3 - .parent() - .unwrap() - .to_owned() + subdirectory.and_then(|subdirectory| { + // NOTE: Just `.uwnrapping()` all of these and using `.map()` + // instead of `.and_then()` should be sufficient, but for some + // reason people add the `x86_64-win` directory inside of a + // VST3 bundle to their plugin locations........why? + Some( + subdirectory + // x86_64-win + .parent()? + // Contents + .parent()? + // foo.vst3 + .parent()? + .to_owned(), + ) }), ) } else {