summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-04-26 10:13:49 +0100
committerCarl Hetherington <cth@carlh.net>2017-04-26 10:13:49 +0100
commit56abd650a3e915c398db8dbeaf5260452234ac9f (patch)
treef430b2122488d3cb56d2e2516caa1102b20fd7ee
parent1bb2e84e9a0037b95bd938abf0955176058a5977 (diff)
Copy config.xml and cinemas.xml if they fail to load so data is not lost.
-rw-r--r--ChangeLog4
-rw-r--r--src/lib/config.cc7
2 files changed, 11 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 178601665..b1ffde15b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-26 Carl Hetherington <cth@carlh.net>
+
+ * Make a copy of the configuration, if it fails to load, before making new defaults.
+
2017-04-07 Carl Hetherington <cth@carlh.net>
* Make jump-to-content-start on selection in the content list
diff --git a/src/lib/config.cc b/src/lib/config.cc
index 01a67522f..10bee140c 100644
--- a/src/lib/config.cc
+++ b/src/lib/config.cc
@@ -323,6 +323,13 @@ try
}
catch (...) {
if (have_existing ("config.xml")) {
+
+ /* Make a copy of the configuration */
+ try {
+ boost::filesystem::copy (path ("config.xml", false), path ("config.xml.backup", false));
+ boost::filesystem::copy (path ("cinemas.xml", false), path ("cinemas.xml.backup", false));
+ } catch (...) {}
+
/* We have a config file but it didn't load */
FailedToLoad ();
}