summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2020-10-28 12:48:48 +0100
committerCarl Hetherington <cth@carlh.net>2020-10-28 12:50:37 +0100
commitedbd3d482734fcd12985252932918776f9ee0bad (patch)
tree53bd3adf173bd5b34c4f059ff15aa48d2644bed8
parentb73549f6c4f13e8ef5cadebbc767829aea5a2c16 (diff)
Prevent import of directories as DCPs if they do not have an
ASSETMAP{,.xml} in the top level. This should avoid some confusion, as previously DoM would scan the whole directory tree looking for an ASSETMAP. It also prevents people adding a DCP-o-matic project to itself, which I believe is the cause of #1620. Backported-from-commit: 2c74c1534cb563cab4c6c3225ced573619f6a647 Backported-from-branch: v2.15.x
-rw-r--r--src/lib/dcp_content.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc
index 2e93e9ee8..458c13787 100644
--- a/src/lib/dcp_content.cc
+++ b/src/lib/dcp_content.cc
@@ -150,18 +150,31 @@ DCPContent::DCPContent (cxml::ConstNodePtr node, int version)
void
DCPContent::read_directory (boost::filesystem::path p)
{
- read_sub_directory (p);
+ using namespace boost::filesystem;
bool have_assetmap = false;
- BOOST_FOREACH (boost::filesystem::path i, paths()) {
- if (i.filename() == "ASSETMAP" || i.filename() == "ASSETMAP.xml") {
+ bool have_metadata = false;
+
+ for (directory_iterator i(p); i != directory_iterator(); ++i) {
+ if (i->path().filename() == "ASSETMAP" || i->path().filename() == "ASSETMAP.xml") {
have_assetmap = true;
+ } else if (i->path().filename() == "metadata.xml") {
+ have_metadata = true;
}
}
if (!have_assetmap) {
- throw DCPError ("No ASSETMAP or ASSETMAP.xml file found: is this a DCP?");
+ if (!have_metadata) {
+ throw DCPError ("No ASSETMAP or ASSETMAP.xml file found: is this a DCP?");
+ } else {
+ throw DCPError (
+ "This looks like a DCP-o-matic project folder, which cannot be added to a different project. "
+ "Choose the DCP directory inside the DCP-o-matic project folder if that's what you want to import."
+ );
+ }
}
+
+ read_sub_directory (p);
}
void