From 83b4d8e69d114c5e1c799a2d23e6314122573d47 Mon Sep 17 00:00:00 2001 From: Noah Hilverling Date: Fri, 13 Nov 2020 17:41:35 +0100 Subject: [PATCH] Config sync: Only remove files, if timestamp changed --- lib/remote/apilistener-filesync.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/remote/apilistener-filesync.cpp b/lib/remote/apilistener-filesync.cpp index 9f48b1d25..fdbc8718e 100644 --- a/lib/remote/apilistener-filesync.cpp +++ b/lib/remote/apilistener-filesync.cpp @@ -421,6 +421,12 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic Dictionary::Ptr productionConfig = MergeConfigUpdate(productionConfigInfo); Dictionary::Ptr newConfig = MergeConfigUpdate(newConfigInfo); + bool timestampChanged = false; + + if (CompareTimestampsConfigChange(productionConfig, newConfig, stageConfigZoneDir)) { + timestampChanged = true; + } + /* If we have received 'checksums' via cluster message, go for it. * Otherwise do the old timestamp dance for versions < 2.11. */ @@ -429,7 +435,7 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic << "Received configuration for zone '" << zoneName << "' from endpoint '" << fromEndpointName << "'. Comparing the timestamp and checksums."; - if (CompareTimestampsConfigChange(productionConfig, newConfig, stageConfigZoneDir)) { + if (timestampChanged) { if (CheckConfigChange(productionConfigInfo, newConfigInfo)) configChange = true; @@ -446,7 +452,7 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic << "Received configuration update without checksums from parent endpoint " << fromEndpointName << ". This behaviour is deprecated. Please upgrade the parent endpoint to 2.11+"; - if (CompareTimestampsConfigChange(productionConfig, newConfig, stageConfigZoneDir)) { + if (timestampChanged) { configChange = true; } @@ -508,8 +514,8 @@ void ApiListener::HandleConfigUpdate(const MessageOrigin::Ptr& origin, const Dic << "Applying configuration file update for path '" << stageConfigZoneDir << "' (" << numBytes << " Bytes)."; - // If the update removes a path, delete it on disk and signal a config change. - { + if (timestampChanged) { + // If the update removes a path, delete it on disk and signal a config change. ObjectLock xlock(productionConfig); for (const Dictionary::Pair& kv : productionConfig) {