From: Carl Hetherington Date: Mon, 3 Apr 2017 22:41:24 +0000 (+0100) Subject: Confirm overwrite of existing DCP when creating a new one. X-Git-Tag: v2.11.1~147 X-Git-Url: https://main.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=988ed4fac88965f2fc260f55a05e2db87bb1ecb8 Confirm overwrite of existing DCP when creating a new one. --- 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 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 read_metadata (boost::optional path = boost::optional ()); 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 film, weak_ptr 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.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.