diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-09-04 21:26:24 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-09-05 23:52:03 +0200 |
| commit | b5cd81225e49fc983777dbf15a38e262fb2dd9f6 (patch) | |
| tree | 8bff752b3fbb726133dec69f85de3142bd2bb681 /src/lib | |
| parent | f5bd787fb71466a6187050086b2890b9b0ac9294 (diff) | |
Let config/cinemas/dkdm_recipients take care of their own recovery.
This should mean that if one fails to load, but the others are OK,
we don't re-write everything. I hope this has no bad side-effects
that I didn't think of.
It's particularly helpful in the case of #2319 where a failure to
load cinemas.xml (which was being created by another tool) caused
the config to be re-written, breaking all existing DKDMs.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/config.cc | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/lib/config.cc b/src/lib/config.cc index 94595f9f8..18c792223 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -608,7 +608,7 @@ try _export.read(f.optional_node_child("Export")); } catch (...) { - if (have_existing("config.xml") || have_existing("cinemas.xml") || have_existing("dkdm_recipients.xml")) { + if (have_existing("config.xml")) { backup (); /* We have a config file but it didn't load */ FailedToLoad(LoadFailure::CONFIG); @@ -618,7 +618,7 @@ catch (...) { _signer_chain = create_certificate_chain (); /* And similar for decryption of KDMs */ _decryption_chain = create_certificate_chain (); - write (); + write_config(); } @@ -626,9 +626,15 @@ void Config::read_cinemas() { if (boost::filesystem::exists (_cinemas_file)) { - cxml::Document f ("Cinemas"); - f.read_file (_cinemas_file); - read_cinemas (f); + try { + cxml::Document f("Cinemas"); + f.read_file(_cinemas_file); + read_cinemas(f); + } catch (...) { + backup(); + FailedToLoad(LoadFailure::CINEMAS); + write_cinemas(); + } } } @@ -637,9 +643,15 @@ void Config::read_dkdm_recipients() { if (boost::filesystem::exists (_dkdm_recipients_file)) { - cxml::Document f ("DKDMRecipients"); - f.read_file (_dkdm_recipients_file); - read_dkdm_recipients (f); + try { + cxml::Document f("DKDMRecipients"); + f.read_file(_dkdm_recipients_file); + read_dkdm_recipients(f); + } catch (...) { + backup(); + FailedToLoad(LoadFailure::DKDM_RECIPIENTS); + write_dkdm_recipients(); + } } } |
