Don't show warning when only removing an empty DKDM folder (#2541).
authorCarl Hetherington <cth@carlh.net>
Tue, 30 May 2023 18:31:53 +0000 (20:31 +0200)
committerCarl Hetherington <cth@carlh.net>
Tue, 30 May 2023 18:31:53 +0000 (20:31 +0200)
src/lib/dkdm_wrapper.cc
src/lib/dkdm_wrapper.h
src/tools/dcpomatic_kdm.cc

index f5eb435f6d0fc06989478a70a21f306b2bb1dd11..016c77c3f9ec4a7671c3f2e8906ea0f0fae55883 100644 (file)
@@ -131,3 +131,15 @@ DKDMGroup::contains(string dkdm_id) const
        return false;
 }
 
        return false;
 }
 
+
+bool
+DKDMGroup::contains_dkdm() const
+{
+       for (auto child: _children) {
+               if (child->contains_dkdm()) {
+                       return true;
+               }
+       }
+
+       return false;
+}
index d15f017c513320710bad7081b26620a4566d535b..7182e5e85794d7c401c851b58e8fd36103d48430 100644 (file)
@@ -38,6 +38,8 @@ public:
        virtual ~DKDMBase () {}
        virtual std::string name () const = 0;
        virtual void as_xml (xmlpp::Element *) const = 0;
        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<DKDMBase> read (cxml::ConstNodePtr node);
 
 
        static std::shared_ptr<DKDMBase> read (cxml::ConstNodePtr node);
 
@@ -63,6 +65,9 @@ public:
 
        std::string name () const override;
        void as_xml (xmlpp::Element *) const override;
 
        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;
 
        dcp::EncryptedKDM dkdm () const {
                return _dkdm;
@@ -86,6 +91,8 @@ public:
 
        void as_xml (xmlpp::Element *) const override;
 
 
        void as_xml (xmlpp::Element *) const override;
 
+       bool contains_dkdm() const override;
+
        std::list<std::shared_ptr<DKDMBase>> children () const {
                return _children;
        }
        std::list<std::shared_ptr<DKDMBase>> children () const {
                return _children;
        }
index 3504943789408cb3ee85e9dbf6caf276164c5ce2..6628c2b3f6734def9a9908fe6de7e9a0da2254ab 100644 (file)
@@ -732,12 +732,14 @@ private:
                        return;
                }
 
                        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));
                }
 
                _dkdm->Delete (dkdm_to_id (removed));