From 95d41fba4688e5a3da5316f02047b84e16aea68b Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 9 Apr 2020 16:48:20 +0200 Subject: [PATCH] Clean up SQLite replay log on logging refs #7752 --- lib/remote/apilistener.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 6af6267b4..7472f20d6 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -1159,8 +1159,18 @@ void ApiListener::PersistMessage(const Dictionary::Ptr& message, const ConfigObj targetEndpoints.erase(GetLocalEndpoint()); + auto now (Utility::GetTime()); + for (auto& endpoint : targetEndpoints) { if (ts > endpoint->GetLocalLogPosition()) { + { + auto logDuration (endpoint->GetLogDuration()); + + if (logDuration >= 0u) { + endpoint->GetReplayLog().Cleanup(now - logDuration); + } + } + endpoint->GetReplayLog().Log(ts, JsonEncode(message)); } }