Clean template dir before overwriting existing template

This commit is contained in:
Robin Gareus 2025-12-08 22:45:35 +01:00
parent d5464b39db
commit 4207b67b73
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04

View file

@ -3164,11 +3164,16 @@ Session::save_template (const string& template_name, const string& description,
template_dir_path = template_name; template_dir_path = template_name;
} }
if (!replace_existing && Glib::file_test (template_dir_path, Glib::FILE_TEST_EXISTS)) { 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"), warning << string_compose(_("Template \"%1\" already exists - new version not created"),
template_dir_path) << endmsg; template_dir_path) << endmsg;
return -2; return -2;
} }
}
if (g_mkdir_with_parents (template_dir_path.c_str(), 0755) != 0) { if (g_mkdir_with_parents (template_dir_path.c_str(), 0755) != 0) {
error << string_compose(_("Could not create directory for Session template\"%1\" (%2)"), error << string_compose(_("Could not create directory for Session template\"%1\" (%2)"),