автоматическое удаление данных несуществующих графиков

This commit is contained in:
Dmitry Borisenko
2022-08-25 02:18:21 +02:00
parent 3ec0071527
commit bc545cc958
3 changed files with 18 additions and 3 deletions

View File

@@ -319,8 +319,13 @@ void sendAllFilesToMQTT() {
while (dir.next()) {
String fname = dir.fileName();
String id = selectToMarker(fname, "-");
SerialPrint("I", "Loging", fname);
sendLogData("/logs/" + fname, id);
if (isItemExist(id)) {
SerialPrint("I", "Loging", fname);
sendLogData("/logs/" + fname, id);
} else {
SerialPrint("i", "Loging", "file '" + fname + "' not used, deleted");
removeFile(directory + "/" + fname);
}
}
}

View File

@@ -182,6 +182,15 @@ String getItemValue(String name) {
return "";
}
// существует ли айтем
bool isItemExist(String name) {
IoTItem* tmp = findIoTItem(name);
if (tmp)
return true;
else
return false;
}
StaticJsonDocument<JSON_BUFFER_SIZE> docForExport;
StaticJsonDocument<JSON_BUFFER_SIZE>* getLocalItemsAsJSON() {