From a8ef2587872ef51748f7e9e14f550770408880e1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 1 Jan 2023 21:48:49 +0100 Subject: Don't write the same asset more than once to an ASSETMAP. --- src/asset_map.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/asset_map.cc b/src/asset_map.cc index c1bafd92..615e1f5e 100644 --- a/src/asset_map.cc +++ b/src/asset_map.cc @@ -112,7 +112,13 @@ AssetMap::Asset::Asset(cxml::ConstNodePtr node, boost::filesystem::path root, dc void AssetMap::add_asset(string id, boost::filesystem::path path, bool pkl) { - _assets.push_back(Asset(id, path, pkl)); + auto iter = std::find_if(_assets.begin(), _assets.end(), [id](Asset const& a) { return a.id() == id; }); + if (iter == _assets.end()) { + _assets.push_back(Asset(id, path, pkl)); + } else { + /* We already have this asset, so let's hope it's actually the same one */ + DCP_ASSERT(iter->path() == path); + } } -- cgit v1.2.3