]> git.ipfire.org Git - thirdparty/snapper.git/commitdiff
- continue with other configs if one config is broken 608/head
authorArvin Schnell <aschnell@suse.de>
Fri, 4 Dec 2020 09:12:22 +0000 (10:12 +0100)
committerArvin Schnell <aschnell@suse.de>
Fri, 4 Dec 2020 09:12:22 +0000 (10:12 +0100)
client/proxy.cc
client/proxy.h
client/systemd-helper.cc
package/snapper.changes

index ce156d0c73ab67b36d2597d8df163397dcf71aaf..c70eb359031b146c4998c9c8886c3acbf0c53153 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) [2016-2017] SUSE LLC
+ * Copyright (c) [2016-2020] SUSE LLC
  *
  * All Rights Reserved.
  *
@@ -55,6 +55,14 @@ ProxyConfig::getValue(const string& key, string& value) const
 }
 
 
+bool
+ProxyConfig::is_yes(const char* key) const
+{
+    map<string, string>::const_iterator pos = values.find(key);
+    return pos != values.end() && pos->second == "yes";
+}
+
+
 SMD
 ProxySnapshot::getSmd() const
 {
index bf0c1db919e157bd8c6ad987d7823ce4f70b8019..77197894ba51ee8165bb7bf662267ab7fc41d933 100644 (file)
@@ -82,6 +82,8 @@ public:
 
     bool getValue(const string& key, string& value) const;
 
+    bool is_yes(const char* key) const;
+
 private:
 
     map<string, string> values;
index b01b0c18a5d8fc5f67ef4d644f4212c9adf10554..9589e5d876357b6855a3902326fa753bb4a07c07 100644 (file)
@@ -72,25 +72,31 @@ timeline(ProxySnappers* snappers, const map<string, string>& userdata)
     map<string, ProxyConfig> configs = snappers->getConfigs();
     for (const map<string, ProxyConfig>::value_type& value : configs)
     {
-       const map<string, string>& raw = value.second.getAllValues();
+       const ProxyConfig& proxy_config = value.second;
 
-       map<string, string>::const_iterator pos1 = raw.find("TIMELINE_CREATE");
-       if (pos1 != raw.end() && pos1->second == "yes")
-       {
-           ProxySnapper* snapper = snappers->getSnapper(value.first);
+       if (!proxy_config.is_yes("TIMELINE_CREATE"))
+           continue;
 
-           SCD scd;
-           scd.description = "timeline";
-           scd.cleanup = "timeline";
-           scd.userdata = userdata;
+       cout << "running timeline for '" << value.first << "'." << endl;
 
-           cout << "running timeline for '" << value.first << "'." << endl;
+       ProxySnapper* snapper = nullptr;
 
-           if (!call_with_error_check([snapper, scd](){ snapper->createSingleSnapshot(scd); }))
-           {
-               cerr << "timeline for '" << value.first << "' failed." << endl;
-               ok = false;
-           }
+       if (!call_with_error_check([&snappers, &snapper, &value](){ snapper = snappers->getSnapper(value.first); }))
+       {
+           cerr << "timeline for '" << value.first << "' failed." << endl;
+           ok = false;
+           continue;
+       }
+
+       SCD scd;
+       scd.description = "timeline";
+       scd.cleanup = "timeline";
+       scd.userdata = userdata;
+
+       if (!call_with_error_check([snapper, scd](){ snapper->createSingleSnapshot(scd); }))
+       {
+           cerr << "timeline for '" << value.first << "' failed." << endl;
+           ok = false;
        }
     }
 
@@ -106,12 +112,27 @@ cleanup(ProxySnappers* snappers)
     map<string, ProxyConfig> configs = snappers->getConfigs();
     for (const map<string, ProxyConfig>::value_type& value : configs)
     {
-       const map<string, string>& raw = value.second.getAllValues();
+       const ProxyConfig& proxy_config = value.second;
+
+       bool do_number = proxy_config.is_yes("NUMBER_CLEANUP");
+       bool do_timeline = proxy_config.is_yes("TIMELINE_CLEANUP");
+       bool do_empty_pre_post = proxy_config.is_yes("EMPTY_PRE_POST_CLEANUP");
+
+       if (!do_number && !do_timeline && !do_empty_pre_post)
+           continue;
+
+       cout << "running cleanup for '" << value.first << "'." << endl;
 
-       ProxySnapper* snapper = snappers->getSnapper(value.first);
+       ProxySnapper* snapper = nullptr;
 
-       map<string, string>::const_iterator pos1 = raw.find("NUMBER_CLEANUP");
-       if (pos1 != raw.end() && pos1->second == "yes")
+       if (!call_with_error_check([&snappers, &snapper, &value](){ snapper = snappers->getSnapper(value.first); }))
+       {
+           cerr << "cleanup for '" << value.first << "' failed." << endl;
+           ok = false;
+           continue;
+       }
+
+       if (do_number)
        {
            cout << "running number cleanup for '" << value.first << "'." << endl;
 
@@ -122,8 +143,7 @@ cleanup(ProxySnappers* snappers)
            }
        }
 
-       map<string, string>::const_iterator pos2 = raw.find("TIMELINE_CLEANUP");
-       if (pos2 != raw.end() && pos2->second == "yes")
+       if (do_timeline)
        {
            cout << "running timeline cleanup for '" << value.first << "'." << endl;
 
@@ -134,8 +154,7 @@ cleanup(ProxySnappers* snappers)
            }
        }
 
-       map<string, string>::const_iterator pos3 = raw.find("EMPTY_PRE_POST_CLEANUP");
-       if (pos3 != raw.end() && pos3->second == "yes")
+       if (do_empty_pre_post)
        {
            cout << "running empty-pre-post cleanup for '" << value.first << "'." << endl;
 
index 0bf1285d49a7bca1588aa23df792544db219ed92..242f7dde91b58819fd6ecf106344ff215d1f5c4e 100644 (file)
@@ -1,3 +1,9 @@
+-------------------------------------------------------------------
+Fri Dec 04 10:05:05 CET 2020 - aschnell@suse.com
+
+- in systemd-helper continue with other configs if one config is
+  broken (gh#openSUSE/snapper#495)
+
 -------------------------------------------------------------------
 Thu Dec 03 10:12:04 CET 2020 - aschnell@suse.com