From 89ddd0fbe39e54b63cef3bcd830cc754136fec16 Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko <49808844+DmitryBorisenko33@users.noreply.github.com> Date: Thu, 8 Sep 2022 19:21:28 +0200 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D1=8F?= =?UTF-8?q?=D0=B5=D0=BC=20keepdays?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/virtual/Logging/Loging.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/modules/virtual/Logging/Loging.cpp b/src/modules/virtual/Logging/Loging.cpp index e1fcf64b..80c9f323 100644 --- a/src/modules/virtual/Logging/Loging.cpp +++ b/src/modules/virtual/Logging/Loging.cpp @@ -24,7 +24,7 @@ class Loging : public IoTItem { SerialPrint("E", F("Loging"), "'" + id + "' user set more points than allowed, value reset to 300"); } jsonRead(parameters, F("int"), interval); - interval = interval * 1000 * 60; + interval = interval * 1000 * 60; //приводим к милисекундам jsonRead(parameters, F("keepdays"), keepdays); } @@ -152,10 +152,18 @@ class Loging : public IoTItem { f++; int i = 0; - createJson(buf, i, mqtt); + unsigned long fileUnixTime = selectToMarkerLast(deleteToMarkerLast(buf, "."), "/").toInt() + START_DATETIME; SerialPrint("i", F("Loging"), String(f) + ") path: " + buf + ", lines №: " + String(i) + ", creation time: " + getDateTimeDotFormatedFromUnix(fileUnixTime)); + //удаление старых файлов + if ((fileUnixTime + (points * (interval / 1000))) < (unixTime - (keepdays * 86400))) { + SerialPrint("i", F("Loging"), "'" + id + "' file '" + buf + "' too old, deleted"); + removeFile(buf); + } else { + createJson(buf, i, mqtt); + } + filesList = deleteBeforeDelimiter(filesList, ";"); } }