From 83c11962b206d2bbf939b8ca5ca58ac52267d610 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 28 Sep 2018 16:58:59 +0200 Subject: [PATCH] Only remove directories if they exist during sync --- lib/remote/apilistener-filesync.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/remote/apilistener-filesync.cpp b/lib/remote/apilistener-filesync.cpp index ffddb51f5..c8afd43af 100644 --- a/lib/remote/apilistener-filesync.cpp +++ b/lib/remote/apilistener-filesync.cpp @@ -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. */