From 5e95c3b4e0fbdb87d8308177c325423bdaac1618 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Mon, 13 Jun 2022 00:06:56 +0200 Subject: [PATCH] Make the VST3 bundle detection more specific In yabridge itself. --- CHANGELOG.md | 8 ++++++++ src/plugin/utils.cpp | 11 +++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 33b7c5d4..84816208 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,14 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Fixed + +- Fixed a rare edge case where a Windows VST3 plugin would incorrectly be + classified as a bundle, causing loading the plugin to fail. This could happen + if the directory `foo` contained some random directory, containing another + directory, containing `foo.vst3`. Yabridge always assumed this to be a bundle, + even if it is not. + ### yabridge - Don't panic when someone `yabridgectl add`'ed part of the contents of a diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp index ae2a7b43..acd431bc 100644 --- a/src/plugin/utils.cpp +++ b/src/plugin/utils.cpp @@ -239,9 +239,16 @@ fs::path normalize_plugin_path(const fs::path& windows_library_path, // an old standalone module const fs::path win_module_name = windows_library_path.filename().replace_extension(".vst3"); + // NOTE: This extra check is needed to prevent + // `/foo/X/Y/foo.vst3` from being recognized as a + // bundle when it isn't in fact a bundle. + const fs::path windows_bundle_contents = + windows_library_path.parent_path().parent_path(); const fs::path windows_bundle_home = - windows_library_path.parent_path().parent_path().parent_path(); - if (equals_case_insensitive(windows_bundle_home.filename().string(), + windows_bundle_contents.parent_path(); + if (equals_case_insensitive(windows_bundle_contents.string(), + "Contents") && + equals_case_insensitive(windows_bundle_home.filename().string(), win_module_name.string())) { return windows_bundle_home; } else {