From: Carl Hetherington Date: Tue, 30 May 2023 18:31:53 +0000 (+0200) Subject: Don't show warning when only removing an empty DKDM folder (#2541). X-Git-Tag: v2.16.58~12 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=ada78c153ca05c2bd3cefcd4b3497af7dde7ec95 Don't show warning when only removing an empty DKDM folder (#2541). --- diff --git a/src/lib/dkdm_wrapper.cc b/src/lib/dkdm_wrapper.cc index f5eb435f6..016c77c3f 100644 --- a/src/lib/dkdm_wrapper.cc +++ b/src/lib/dkdm_wrapper.cc @@ -131,3 +131,15 @@ DKDMGroup::contains(string dkdm_id) const return false; } + +bool +DKDMGroup::contains_dkdm() const +{ + for (auto child: _children) { + if (child->contains_dkdm()) { + return true; + } + } + + return false; +} diff --git a/src/lib/dkdm_wrapper.h b/src/lib/dkdm_wrapper.h index d15f017c5..7182e5e85 100644 --- a/src/lib/dkdm_wrapper.h +++ b/src/lib/dkdm_wrapper.h @@ -38,6 +38,8 @@ public: virtual ~DKDMBase () {} virtual std::string name () const = 0; virtual void as_xml (xmlpp::Element *) const = 0; + /** @return true if this thing is, or contains, any actual DKDM */ + virtual bool contains_dkdm() const = 0; static std::shared_ptr read (cxml::ConstNodePtr node); @@ -63,6 +65,9 @@ public: std::string name () const override; void as_xml (xmlpp::Element *) const override; + bool contains_dkdm() const override { + return true; + } dcp::EncryptedKDM dkdm () const { return _dkdm; @@ -86,6 +91,8 @@ public: void as_xml (xmlpp::Element *) const override; + bool contains_dkdm() const override; + std::list> children () const { return _children; } diff --git a/src/tools/dcpomatic_kdm.cc b/src/tools/dcpomatic_kdm.cc index 350494378..6628c2b3f 100644 --- a/src/tools/dcpomatic_kdm.cc +++ b/src/tools/dcpomatic_kdm.cc @@ -732,12 +732,14 @@ private: return; } - if (NagDialog::maybe_nag ( - this, Config::NAG_DELETE_DKDM, - _("You are about to remove a DKDM. This will make it impossible to decrypt the DCP that the DKDM was made for, and it cannot be undone. " - "Are you sure?"), - true)) { - return; + if (removed->contains_dkdm()) { + if (NagDialog::maybe_nag( + this, Config::NAG_DELETE_DKDM, + _("You are about to remove a DKDM. This will make it impossible to decrypt the DCP that the DKDM was made for, and it cannot be undone. " + "Are you sure?"), + true)) { + return; + } } _dkdm->Delete (dkdm_to_id (removed));