diff --git a/lib/remote/apilistener-sync.cpp b/lib/remote/apilistener-sync.cpp index 78ae5cf060e..84a1aa815a6 100644 --- a/lib/remote/apilistener-sync.cpp +++ b/lib/remote/apilistener-sync.cpp @@ -21,6 +21,7 @@ #include "remote/apifunction.h" #include "base/dynamictype.h" #include "base/logger_fwd.h" +#include "base/convert.h" #include #include @@ -57,6 +58,14 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio { bool configChange = false; + if (oldConfig->Contains(".timestamp") && newConfig->Contains(".timestamp")) { + double oldTS = Convert::ToDouble(oldConfig->Get(".timestamp")); + double newTS = Convert::ToDouble(newConfig->Get(".timestamp")); + + /* skip update if our config is newer */ + if (oldTS <= newTS) + return false; + } BOOST_FOREACH(const Dictionary::Pair& kv, newConfig) { if (oldConfig->Get(kv.first) != kv.second) { @@ -80,6 +89,13 @@ bool ApiListener::UpdateConfigDir(const Dictionary::Ptr& oldConfig, const Dictio } } + String tsPath = configDir + "/.timestamp"; + if (!Utility::PathExists(tsPath)) { + std::ofstream fp(tsPath.CStr(), std::ofstream::out | std::ostream::trunc); + fp << Utility::GetTime(); + fp.close(); + } + return configChange; }