From e0db21d484d968666a0795cf6630ad8b62f31ddf Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 27 Mar 2024 21:37:03 +0100 Subject: [PATCH] Save versioned backups in backup/ folder This makes it harder for users to accidentally open session files which are intended to be used only with older versions of Ardour. Note that backup/ is not included in ::find_all_sources_across_snapshots so Session > Cleanup can remove files used in old backups. --- libs/ardour/session_state.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 4e1de120f6..a74ec00194 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -1026,7 +1026,13 @@ Session::load_state (string snapshot_name, bool from_template) if (Stateful::loading_state_version < CURRENT_SESSION_FILE_VERSION && _writable && !from_template) { - std::string backup_path(_session_dir->root_path()); + std::string backup_path (_session_dir->backup_path()); + if (!Glib::file_test (backup_path, Glib::FILE_TEST_EXISTS | Glib::FILE_TEST_IS_DIR)) { + if (g_mkdir_with_parents (backup_path.c_str(), 0755) < 0) { + backup_path = _session_dir->root_path (); + } + } + std::string backup_filename = string_compose ("%1-%2%3", legalize_for_path (snapshot_name), Stateful::loading_state_version, statefile_suffix); backup_path = Glib::build_filename (backup_path, backup_filename);