From 333f59a53f2ba62d751bf8cc767e79d4af980aee Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 10 Jul 2018 00:57:04 +0200 Subject: [PATCH] Fix lv2-state templates with external files. This forces liblilv to collect external files in the template-folder and symlink to the original file instead of re-using the external-file folder of the session that was used to create the template. --- libs/ardour/lv2_plugin.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc index 1fd54c6286..6f8dad9396 100644 --- a/libs/ardour/lv2_plugin.cc +++ b/libs/ardour/lv2_plugin.cc @@ -51,6 +51,7 @@ #include "ardour/audio_buffer.h" #include "ardour/audioengine.h" +#include "ardour/directory_names.h" #include "ardour/debug.h" #include "ardour/lv2_plugin.h" #include "ardour/midi_patch_manager.h" @@ -1380,13 +1381,20 @@ LV2Plugin::add_state(XMLNode* root) const unsigned int saved_state = _state_version;; g_mkdir_with_parents(new_dir.c_str(), 0744); + std::string xternal_dir = _session.externals_dir (); + + if (!_plugin_state_dir.empty()) { + xternal_dir = Glib::build_filename (_plugin_state_dir, externals_dir_name); + g_mkdir_with_parents(xternal_dir.c_str(), 0744); + } + LilvState* state = lilv_state_new_from_instance( _impl->plugin, _impl->instance, _uri_map.urid_map(), scratch_dir().c_str(), file_dir().c_str(), - _session.externals_dir().c_str(), + xternal_dir.c_str(), new_dir.c_str(), NULL, const_cast(this), @@ -1416,6 +1424,7 @@ LV2Plugin::add_state(XMLNode* root) const } else { // template save (dedicated state-dir) lilv_state_free(state); + g_rmdir (xternal_dir.c_str()); // try remove unused dir --_state_version; } } else { -- 2.30.2