diff options
| author | Carl Hetherington <cth@carlh.net> | 2023-01-01 01:40:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2023-01-07 22:49:27 +0100 |
| commit | 02fc2c110a9e8b338e05388aa59cc52ea85fbf3f (patch) | |
| tree | dc1b0b1c3dec05b6eded504794a3db820eeae3a7 | |
| parent | b27b2ce330d73c78b45efcc1bbbcf7117409ed73 (diff) | |
Don't write the same asset more than once to a PKL (#2402).
| -rw-r--r-- | src/pkl.cc | 8 | ||||
| -rw-r--r-- | test/combine_test.cc | 22 |
2 files changed, 29 insertions, 1 deletions
@@ -89,7 +89,13 @@ PKL::PKL (boost::filesystem::path file) void PKL::add_asset(std::string id, boost::optional<std::string> annotation_text, std::string hash, int64_t size, std::string type, std::string original_filename) { - _assets.push_back(make_shared<Asset>(id, annotation_text, hash, size, type, original_filename)); + auto iter = std::find_if(_assets.begin(), _assets.end(), [id](shared_ptr<Asset> a) { return a->id() == id; }); + if (iter == _assets.end()) { + _assets.push_back(make_shared<Asset>(id, annotation_text, hash, size, type, original_filename)); + } else { + /* We already have this asset, so let's hope it's actually the same one */ + DCP_ASSERT((*iter)->hash() == hash); + } } diff --git a/test/combine_test.cc b/test/combine_test.cc index 709ec080..674e1a97 100644 --- a/test/combine_test.cc +++ b/test/combine_test.cc @@ -231,6 +231,28 @@ BOOST_AUTO_TEST_CASE (combine_two_dcps_with_interop_subs_test) } +BOOST_AUTO_TEST_CASE(combine_two_dcps_with_interop_subs_same_font_id_test) +{ + using namespace boost::algorithm; + using namespace boost::filesystem; + boost::filesystem::path const out = "build/test/combine_two_dcps_with_interop_subs_same_font_id_test"; + + auto font_uuid = dcp::make_uuid(); + auto first = make_simple_with_interop_subs("build/test/combine_input1", font_uuid); + first->write_xml (); + + auto second = make_simple_with_interop_subs("build/test/combine_input2", font_uuid); + second->write_xml (); + + remove_all (out); + vector<path> inputs = {"build/test/combine_input1", "build/test/combine_input2"}; + dcp::combine(inputs, out); + + check_no_errors(out); + check_combined(inputs, out); +} + + BOOST_AUTO_TEST_CASE (combine_two_dcps_with_smpte_subs_test) { using namespace boost::algorithm; |
