summaryrefslogtreecommitdiff
path: root/src/lib/map_cli.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-05-30 17:21:24 +0200
committerCarl Hetherington <cth@carlh.net>2023-05-30 17:21:24 +0200
commitdebc0ef69468530ba482c8ed0fc6a1ac1f26b26e (patch)
treec6c2253f3f5df3084001d921379c3a4a1c6ab2ef /src/lib/map_cli.cc
parentbe911c68ee4fdc98a8c406d0f10e9d71c69714c0 (diff)
Fix errors when mapping DCPs referring to the same asset multiple times (#2542).
Diffstat (limited to 'src/lib/map_cli.cc')
-rw-r--r--src/lib/map_cli.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/map_cli.cc b/src/lib/map_cli.cc
index c95d7f1a1..c49964f80 100644
--- a/src/lib/map_cli.cc
+++ b/src/lib/map_cli.cc
@@ -196,13 +196,20 @@ map_cli(int argc, char* argv[], std::function<void (string)> out)
CopyError(std::string message) : std::runtime_error(message) {}
};
- auto maybe_copy = [&assets, output_dir](
+ vector<string> already_copied;
+
+ auto maybe_copy = [&assets, &already_copied, output_dir](
string asset_id,
bool rename,
bool hard_link,
bool soft_link,
boost::optional<boost::filesystem::path> extra = boost::none
) {
+
+ if (std::find(already_copied.begin(), already_copied.end(), asset_id) != already_copied.end()) {
+ return;
+ }
+
auto iter = std::find_if(assets.begin(), assets.end(), [asset_id](shared_ptr<const dcp::Asset> a) { return a->id() == asset_id; });
if (iter != assets.end()) {
DCP_ASSERT((*iter)->file());
@@ -240,6 +247,7 @@ map_cli(int argc, char* argv[], std::function<void (string)> out)
}
}
(*iter)->set_file(output_path);
+ already_copied.push_back(asset_id);
} else {
boost::system::error_code ec;
boost::filesystem::remove_all(*output_dir, ec);