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.
This commit is contained in:
Robin Gareus 2024-03-27 21:37:03 +01:00
parent 41115f1282
commit e0db21d484
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
1 changed files with 7 additions and 1 deletions

View File

@ -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);