]> granicus.if.org Git - icinga2/commitdiff
Only remove directories if they exist during sync
authorMichael Friedrich <michael.friedrich@icinga.com>
Fri, 28 Sep 2018 14:58:59 +0000 (16:58 +0200)
committerMichael Friedrich <michael.friedrich@icinga.com>
Wed, 19 Jun 2019 12:46:11 +0000 (14:46 +0200)
lib/remote/apilistener-filesync.cpp

index ffddb51f5d0b4abf4c9ee6c034af3c292fa53479..c8afd43af6971d5e9dd5c7dd183249cef7c62dcc 100644 (file)
@@ -310,7 +310,10 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D
         * runtime production config and newly received configuration.
         */
        String apiZonesStageDir = GetApiZonesStageDir();
-       Utility::RemoveDirRecursive(apiZonesStageDir);
+
+       if (Utility::PathExists(apiZonesStageDir))
+               Utility::RemoveDirRecursive(apiZonesStageDir);
+
        Utility::MkDirP(apiZonesStageDir, 0700);
 
        ObjectLock olock(updateV1);
@@ -388,7 +391,9 @@ void ApiListener::TryActivateZonesStageCallback(const ProcessResult& pr,
                String apiZonesDir = GetApiZonesDir();
 
                /* Purge production before copying stage. */
-               Utility::RemoveDirRecursive(apiZonesDir);
+               if (Utility::PathExists(apiZonesDir))
+                       Utility::RemoveDirRecursive(apiZonesDir);
+
                Utility::MkDirP(apiZonesDir, 0700);
 
                /* Copy all synced configuration files from stage to production. */