From 0897057954047eabfe4df9bdab0cc548fe1c68bf Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 9 Feb 2019 21:09:16 +0000 Subject: [PATCH 1/1] Back up old metadata.xml files when we are about to save a new version of them. --- src/lib/film.cc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/film.cc b/src/lib/film.cc index e7861a032..f1d066f34 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -454,6 +454,16 @@ Film::read_metadata (optional path) _state_version = f.number_child ("Version"); if (_state_version > current_state_version) { throw runtime_error (_("This film was created with a newer version of DCP-o-matic, and it cannot be loaded into this version. Sorry!")); + } else if (_state_version < current_state_version) { + /* This is an older version; save a copy (if we haven't already) */ + boost::filesystem::path const older = path->parent_path() / String::compose("metadata.%1.xml", _state_version); + if (!boost::filesystem::is_regular_file(older)) { + try { + boost::filesystem::copy_file(*path, older); + } catch (...) { + /* Never mind; at least we tried */ + } + } } _name = f.string_child ("Name"); -- 2.30.2