From ffc5d1474af146d26f2ac3fe5e637575784eb3af Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Sat, 14 Jul 2018 12:46:49 -0500 Subject: auto-backup: libardour part. (from mixbus) --- libs/ardour/session_state.cc | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'libs/ardour/session_state.cc') diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index b27a292642..6eb06d8c35 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -749,6 +749,8 @@ Session::remove_state (string snapshot_name) error << string_compose(_("Could not remove session file at path \"%1\" (%2)"), xml_path, g_strerror (errno)) << endmsg; } + + StateSaved (snapshot_name); /* EMIT SIGNAL */ } /** @param snapshot_name Name to save under, without .ardour / .pending prefix */ @@ -873,6 +875,32 @@ Session::save_state (string snapshot_name, bool pending, bool switch_to_snapshot } } + //Mixbus auto-backup mechanism + if(Profile->get_mixbus()) { + if (pending) { //"pending" save means it's a backup, or some other non-user-initiated save; a good time to make a backup + // make a serialized safety backup + // (will make one periodically but only one per hour is left on disk) + // these backup files go into a separated folder + char timebuf[128]; + time_t n; + struct tm local_time; + time (&n); + localtime_r (&n, &local_time); + strftime (timebuf, sizeof(timebuf), "%y-%m-%d.%H", &local_time); + std::string save_path(session_directory().backup_path()); + save_path += G_DIR_SEPARATOR; + save_path += legalize_for_path(_current_snapshot_name); + save_path += "-"; + save_path += timebuf; + save_path += statefile_suffix; + if ( !tree.write (save_path) ) + error << string_compose(_("Could not save backup file at path \"%1\" (%2)"), + save_path, g_strerror (errno)) << endmsg; + } + + StateSaved (snapshot_name); /* EMIT SIGNAL */ + } + if (!pending && !for_archive) { save_history (snapshot_name); -- cgit v1.2.3