Skip to content

Commit 14cb049

Browse files
committed
Implement timestamps for zone configs.
Fixes #6191
1 parent dcbe7e1 commit 14cb049

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/remote/apilistener-sync.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "remote/apifunction.h"
2222
#include "base/dynamictype.h"
2323
#include "base/logger_fwd.h"
24+
#include "base/convert.h"
2425
#include <boost/foreach.hpp>
2526
#include <fstream>
2627

@@ -57,6 +58,14 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio
5758
{
5859
bool configChange = false;
5960

61+
if (oldConfig->Contains(".timestamp") && newConfig->Contains(".timestamp")) {
62+
double oldTS = Convert::ToDouble(oldConfig->Get(".timestamp"));
63+
double newTS = Convert::ToDouble(newConfig->Get(".timestamp"));
64+
65+
/* skip update if our config is newer */
66+
if (oldTS <= newTS)
67+
return false;
68+
}
6069

6170
BOOST_FOREACH(const Dictionary::Pair& kv, newConfig) {
6271
if (oldConfig->Get(kv.first) != kv.second) {
@@ -80,6 +89,13 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio
8089
}
8190
}
8291

92+
String tsPath = configDir + "/.timestamp";
93+
if (!Utility::PathExists(tsPath)) {
94+
std::ofstream fp(tsPath.CStr(), std::ofstream::out | std::ostream::trunc);
95+
fp << Utility::GetTime();
96+
fp.close();
97+
}
98+
8399
return configChange;
84100
}
85101

0 commit comments

Comments
 (0)