From e5e9b477d0a4513ca44dd61c458d5cd76d924f45 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Fri, 6 Jan 2023 00:52:28 +0100 Subject: [PATCH] Force rescan of VST3 plugins --- libs/ardour/plugin_manager.cc | 12 ++---------- libs/ardour/vst3_scan.cc | 18 ++++++++++++++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/libs/ardour/plugin_manager.cc b/libs/ardour/plugin_manager.cc index 766ba4529f..3d1befb552 100644 --- a/libs/ardour/plugin_manager.cc +++ b/libs/ardour/plugin_manager.cc @@ -5,7 +5,7 @@ * Copyright (C) 2009-2012 Carl Hetherington * Copyright (C) 2012-2015 Tim Mayberry * Copyright (C) 2014-2018 John Emmas - * Copyright (C) 2014-2019 Robin Gareus + * Copyright (C) 2014-2023 Robin Gareus * Copyright (C) 2018 Ben Loftis * * This program is free software; you can redistribute it and/or modify @@ -2149,15 +2149,7 @@ PluginManager::vst3_discover (string const& path, bool cache_only) XMLTree tree; if (cache_file.empty ()) { run_scan = true; - } else if (tree.read (cache_file)) { - /* valid cache file was found, now check version - * see ARDOUR::vst3_scan_and_cache VST3Cache version - */ - int cf_version = 0; - if (!tree.root()->get_property ("version", cf_version) || cf_version < 1) { - run_scan = true; - } - } else { + } else if (!tree.read (cache_file)) { /* failed to parse XML */ run_scan = true; } diff --git a/libs/ardour/vst3_scan.cc b/libs/ardour/vst3_scan.cc index 58cf6e3cf3..f1a0c94952 100644 --- a/libs/ardour/vst3_scan.cc +++ b/libs/ardour/vst3_scan.cc @@ -47,6 +47,8 @@ using namespace std; using namespace Steinberg; +#define ARDOUR_VST3_CACHE_FILE_VERSION 2 + static const char* fmt_media (Vst::MediaType m) { switch (m) { case Vst::kAudio: return "kAudio"; @@ -392,8 +394,20 @@ ARDOUR::vst3_valid_cache_file (std::string const& module_path, bool verbose, boo if (sb_vst.st_mtime < sb_v3i.st_mtime) { /* plugin is older than cache file */ if (verbose) { - PBD::info << "Cache file is up-to-date." << endmsg; + PBD::info << "Cache file timestamp is valid." << endmsg; } + /* check file format version */ + XMLTree tree; + if (!tree.read (cache_file)) { + PBD::info << "Cache file is not valid XML." << endmsg; + return ""; + } + int cf_version = 0; + if (!tree.root()->get_property ("version", cf_version) || cf_version < ARDOUR_VST3_CACHE_FILE_VERSION) { + PBD::info << "Cache file version is too old." << endmsg; + return ""; + } + PBD::info << "Cache file is valid and up-to-date." << endmsg; return cache_file; } else if (verbose) { PBD::info << "Stale cache." << endmsg; @@ -454,7 +468,7 @@ bool ARDOUR::vst3_scan_and_cache (std::string const& module_path, std::string const& bundle_path, boost::function cb, bool verbose) { XMLNode* root = new XMLNode ("VST3Cache"); - root->set_property ("version", 1); + root->set_property ("version", ARDOUR_VST3_CACHE_FILE_VERSION); root->set_property ("bundle", bundle_path); root->set_property ("module", module_path);