diff options
| author | Carl Hetherington <cth@carlh.net> | 2019-02-09 21:09:16 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2019-02-09 21:09:16 +0000 |
| commit | 0897057954047eabfe4df9bdab0cc548fe1c68bf (patch) | |
| tree | 62a07f8f1829ccc7c4e1d2f6c9856c8f1f0845f1 /src | |
| parent | dc5a2865d004ba56f8cbbdb3a56668a3967d1aa2 (diff) | |
Back up old metadata.xml files when we are about to save a new version of them.v2.13.116
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/film.cc | 10 |
1 files changed, 10 insertions, 0 deletions
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<boost::filesystem::path> path) _state_version = f.number_child<int> ("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"); |
