From 4207b67b73c44b6497e51316a2314ac008cc9e29 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Mon, 8 Dec 2025 22:45:35 +0100 Subject: [PATCH] Clean template dir before overwriting existing template --- libs/ardour/session_state.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 4d98c033dc..a772ba6b2e 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -3164,10 +3164,15 @@ Session::save_template (const string& template_name, const string& description, template_dir_path = template_name; } - if (!replace_existing && Glib::file_test (template_dir_path, Glib::FILE_TEST_EXISTS)) { - warning << string_compose(_("Template \"%1\" already exists - new version not created"), - template_dir_path) << endmsg; - return -2; + if (Glib::file_test (template_dir_path, Glib::FILE_TEST_EXISTS)) { + if (replace_existing) { + /* clean out old plugin state, etc */ + remove_directory (template_dir_path); + } else { + warning << string_compose(_("Template \"%1\" already exists - new version not created"), + template_dir_path) << endmsg; + return -2; + } } if (g_mkdir_with_parents (template_dir_path.c_str(), 0755) != 0) {