diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-02-10 21:06:43 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-02-10 21:16:09 +0100 |
| commit | ec2f9869126bb5fa19c21e5272456976e7b7ad8a (patch) | |
| tree | cf4d711a8c9e4fd6cf01cd551b6acf838d6b0425 /src | |
| parent | 47eb4bb86b59bd2e28dceac857397ae8df8ed1de (diff) | |
Don't give up on backups if config.xml isn't there (#2185).
Even if it isn't, we still want to try to back up other stuff.
Previously if copying config.xml threw an exception we'd just
give up.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/config.cc | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index 5496c0b3c..0d70c16fc 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -227,7 +227,8 @@ Config::backup () while (n < 100 && exists(add_number(path_to_copy, n))) { ++n; } - copy_file(path_to_copy, add_number(path_to_copy, n)); + boost::system::error_code ec; + copy_file(path_to_copy, add_number(path_to_copy, n), ec); }; /* Make a backup copy of any config.xml, cinemas.xml, dkdm_recipients.xml that we might be about @@ -235,18 +236,17 @@ Config::backup () * and decide to overwrite it with a new one (possibly losing important details in the corrupted * file). But we might as well back up the other files while we're about it. */ - try { - /* This uses the State::write_path stuff so, e.g. for a current version 2.16 we might copy - * ~/.config/dcpomatic2/2.16/config.xml to ~/.config/dcpomatic2/2.16/config.xml.1 - */ - copy_adding_number (config_write_file()); - /* These do not use State::write_path, so whatever path is in the Config we will copy - * adding a number. - */ - copy_adding_number (_cinemas_file); - copy_adding_number (_dkdm_recipients_file); - } catch (...) {} + /* This uses the State::write_path stuff so, e.g. for a current version 2.16 we might copy + * ~/.config/dcpomatic2/2.16/config.xml to ~/.config/dcpomatic2/2.16/config.xml.1 + */ + copy_adding_number (config_write_file()); + + /* These do not use State::write_path, so whatever path is in the Config we will copy + * adding a number. + */ + copy_adding_number (_cinemas_file); + copy_adding_number (_dkdm_recipients_file); } void @@ -591,7 +591,7 @@ try } } catch (...) { - if (have_existing ("config.xml")) { + if (have_existing("config.xml") || have_existing("cinemas.xml") || have_existing("dkdm_recipients.xml")) { backup (); /* We have a config file but it didn't load */ FailedToLoad (); |
