summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2017-04-03 23:41:24 +0100
committerCarl Hetherington <cth@carlh.net>2017-04-03 23:41:24 +0100
commit988ed4fac88965f2fc260f55a05e2db87bb1ecb8 (patch)
tree4b0899703cfbcca3b2f9c880446aa570dddb73c5
parent77da11b5e09820f8f5babac6d17ff35c0098c96e (diff)
Confirm overwrite of existing DCP when creating a new one.
-rw-r--r--src/lib/film.cc9
-rw-r--r--src/lib/film.h2
-rw-r--r--src/lib/writer.cc3
-rw-r--r--src/tools/dcpomatic.cc10
4 files changed, 17 insertions, 7 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc
index dd31388b6..56dce56e5 100644
--- a/src/lib/film.cc
+++ b/src/lib/film.cc
@@ -509,10 +509,11 @@ Film::read_metadata (optional<boost::filesystem::path> path)
}
/** Given a directory name, return its full path within the Film's directory.
- * The directory (and its parents) will be created if they do not exist.
+ * @param d directory name within the Filn's directory.
+ * @param create true to create the directory (and its parents) if they do not exist.
*/
boost::filesystem::path
-Film::dir (boost::filesystem::path d) const
+Film::dir (boost::filesystem::path d, bool create) const
{
DCPOMATIC_ASSERT (_directory);
@@ -520,7 +521,9 @@ Film::dir (boost::filesystem::path d) const
p /= _directory.get();
p /= d;
- boost::filesystem::create_directories (p);
+ if (create) {
+ boost::filesystem::create_directories (p);
+ }
return p;
}
diff --git a/src/lib/film.h b/src/lib/film.h
index 2b700b007..1d8af39d8 100644
--- a/src/lib/film.h
+++ b/src/lib/film.h
@@ -89,7 +89,7 @@ public:
}
boost::filesystem::path file (boost::filesystem::path f) const;
- boost::filesystem::path dir (boost::filesystem::path d) const;
+ boost::filesystem::path dir (boost::filesystem::path d, bool create = true) const;
void use_template (std::string name);
std::list<std::string> read_metadata (boost::optional<boost::filesystem::path> path = boost::optional<boost::filesystem::path> ());
diff --git a/src/lib/writer.cc b/src/lib/writer.cc
index ccd6d74d1..595915883 100644
--- a/src/lib/writer.cc
+++ b/src/lib/writer.cc
@@ -79,9 +79,6 @@ Writer::Writer (shared_ptr<const Film> film, weak_ptr<Job> j)
, _repeat_written (0)
, _pushed_to_disk (0)
{
- /* Remove any old DCP */
- boost::filesystem::remove_all (_film->dir (_film->dcp_name ()));
-
shared_ptr<Job> job = _job.lock ();
DCPOMATIC_ASSERT (job);
diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc
index 92de9a1f0..f94c2ac54 100644
--- a/src/tools/dcpomatic.cc
+++ b/src/tools/dcpomatic.cc
@@ -496,6 +496,16 @@ private:
}
}
+
+ /* Remove any existing DCP if the user agrees */
+ boost::filesystem::path const dcp_dir = _film->dir (_film->dcp_name(), false);
+ if (boost::filesystem::exists (dcp_dir)) {
+ if (!confirm_dialog (this, wxString::Format (_("Do you want to overwrite the existing DCP %s?"), std_to_wx(dcp_dir.string()).data()))) {
+ return;
+ }
+ boost::filesystem::remove_all (dcp_dir);
+ }
+
try {
/* It seems to make sense to auto-save metadata here, since the make DCP may last
a long time, and crashes/power failures are moderately likely.