mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-14 23:46:52 +03:00
Merge pull request #1189 from Slider0007/rolling
Fix for image logging + file deletion routines
This commit is contained in:
@@ -65,7 +65,7 @@ void ClassFlowImage::LogImage(string logPath, string name, float *resultFloat, i
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
sprintf(buf, "%.1f_", *resultFloat);
|
sprintf(buf, "%.1f_", *resultFloat);
|
||||||
if (strcmp(buf, "10.0_"))
|
if (strcmp(buf, "10.0_") == 0)
|
||||||
sprintf(buf, "0.0_");
|
sprintf(buf, "0.0_");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,14 +119,16 @@ void ClassFlowImage::RemoveOldLogs()
|
|||||||
string folderPath = LogImageLocation + "/" + entry->d_name;
|
string folderPath = LogImageLocation + "/" + entry->d_name;
|
||||||
if (entry->d_type == DT_DIR) {
|
if (entry->d_type == DT_DIR) {
|
||||||
//ESP_LOGI(logTag, "Compare %s %s", entry->d_name, folderName.c_str());
|
//ESP_LOGI(logTag, "Compare %s %s", entry->d_name, folderName.c_str());
|
||||||
if ((strlen(entry->d_name) == folderName.length()) && (strcmp(entry->d_name, folderName.c_str()) < 0)) {
|
if ((strlen(entry->d_name) == folderName.length()) && (strcmp(entry->d_name, folderName.c_str()) == 0)) {
|
||||||
deleted += removeFolder(folderPath.c_str(), logTag);
|
removeFolder(folderPath.c_str(), logTag);
|
||||||
|
deleted++;
|
||||||
} else {
|
} else {
|
||||||
notDeleted ++;
|
notDeleted ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGI(logTag, "%d older log files deleted. %d current log files not deleted.", deleted, notDeleted);
|
ESP_LOGI(logTag, "%d image folder deleted. %d image folder not deleted.", deleted, notDeleted);
|
||||||
|
LogFile.WriteToFile("Image folder deleted: " + std::to_string(deleted) + ". Image folder not deleted: " + std::to_string(notDeleted));
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -319,7 +319,7 @@ string getDirectory(string filename)
|
|||||||
|
|
||||||
string getFileType(string filename)
|
string getFileType(string filename)
|
||||||
{
|
{
|
||||||
size_t lastpos = filename.find(".", 0);
|
size_t lastpos = filename.rfind(".", filename.length());
|
||||||
size_t neu_pos;
|
size_t neu_pos;
|
||||||
while ((neu_pos = filename.find(".", lastpos + 1)) > -1)
|
while ((neu_pos = filename.find(".", lastpos + 1)) > -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -176,7 +176,7 @@ void ClassLogFile::RemoveOld()
|
|||||||
while ((entry = readdir(dir)) != NULL) {
|
while ((entry = readdir(dir)) != NULL) {
|
||||||
if (entry->d_type == DT_REG) {
|
if (entry->d_type == DT_REG) {
|
||||||
//ESP_LOGI(TAG, "list log file : %s %s", entry->d_name, cmpfilename);
|
//ESP_LOGI(TAG, "list log file : %s %s", entry->d_name, cmpfilename);
|
||||||
if ((strlen(entry->d_name) == strlen(cmpfilename)) && (strcmp(entry->d_name, cmpfilename) < 0)) {
|
if ((strlen(entry->d_name) == strlen(cmpfilename)) && (strcmp(entry->d_name, cmpfilename) == 0)) {
|
||||||
ESP_LOGI(TAG, "delete log file : %s", entry->d_name);
|
ESP_LOGI(TAG, "delete log file : %s", entry->d_name);
|
||||||
std::string filepath = logroot + "/" + entry->d_name;
|
std::string filepath = logroot + "/" + entry->d_name;
|
||||||
if (unlink(filepath.c_str()) == 0) {
|
if (unlink(filepath.c_str()) == 0) {
|
||||||
@@ -189,7 +189,8 @@ void ClassLogFile::RemoveOld()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ESP_LOGI(TAG, "%d older log files deleted. %d current log files not deleted.", deleted, notDeleted);
|
ESP_LOGI(TAG, "%d logfiles deleted. %d files not deleted (incl. leer.txt).", deleted, notDeleted);
|
||||||
|
LogFile.WriteToFile("logfiles deleted: " + std::to_string(deleted) + " files not deleted (incl. leer.txt): " + std::to_string(notDeleted));
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user