Fix cookie usage, use correct http response codes, add 404 page (#1495)

* replaced some HTTP response code with better matching codes

* add custom 404 page, add log entry for debugging

* fix cookie

* replace non-necessary whitespace

* .

Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
CaCO3
2022-12-06 06:53:05 +01:00
committed by GitHub
parent fa406d8989
commit 4f07c88769
12 changed files with 82 additions and 67 deletions

View File

@@ -315,7 +315,7 @@ void ClassLogFile::RemoveOldLogFile()
DIR *dir = opendir(logroot.c_str());
if (!dir) {
ESP_LOGE(TAG, "Failed to stat dir : %s", logroot.c_str());
ESP_LOGE(TAG, "Failed to stat dir: %s", logroot.c_str());
return;
}
@@ -324,14 +324,14 @@ void ClassLogFile::RemoveOldLogFile()
int notDeleted = 0;
while ((entry = readdir(dir)) != NULL) {
if (entry->d_type == DT_REG) {
//ESP_LOGD(TAG, "compare log file : %s to %s", entry->d_name, cmpfilename);
//ESP_LOGD(TAG, "compare log file: %s to %s", entry->d_name, cmpfilename);
if ((strlen(entry->d_name) == strlen(cmpfilename)) && (strcmp(entry->d_name, cmpfilename) < 0)) {
//ESP_LOGD(TAG, "delete log file : %s", entry->d_name);
//ESP_LOGD(TAG, "delete log file: %s", entry->d_name);
std::string filepath = logroot + "/" + entry->d_name;
if (unlink(filepath.c_str()) == 0) {
deleted ++;
} else {
ESP_LOGE(TAG, "can't delete file : %s", entry->d_name);
ESP_LOGE(TAG, "can't delete file: %s", entry->d_name);
notDeleted ++;
}
} else {
@@ -366,7 +366,7 @@ void ClassLogFile::RemoveOldDataLog()
DIR *dir = opendir(dataroot.c_str());
if (!dir) {
ESP_LOGE(TAG, "Failed to stat dir : %s", dataroot.c_str());
ESP_LOGE(TAG, "Failed to stat dir: %s", dataroot.c_str());
return;
}
@@ -375,14 +375,14 @@ void ClassLogFile::RemoveOldDataLog()
int notDeleted = 0;
while ((entry = readdir(dir)) != NULL) {
if (entry->d_type == DT_REG) {
//ESP_LOGD(TAG, "Compare data file : %s to %s", entry->d_name, cmpfilename);
//ESP_LOGD(TAG, "Compare data file: %s to %s", entry->d_name, cmpfilename);
if ((strlen(entry->d_name) == strlen(cmpfilename)) && (strcmp(entry->d_name, cmpfilename) < 0)) {
//ESP_LOGD(TAG, "delete data file : %s", entry->d_name);
//ESP_LOGD(TAG, "delete data file: %s", entry->d_name);
std::string filepath = dataroot + "/" + entry->d_name;
if (unlink(filepath.c_str()) == 0) {
deleted ++;
} else {
ESP_LOGE(TAG, "can't delete file : %s", entry->d_name);
ESP_LOGE(TAG, "can't delete file: %s", entry->d_name);
notDeleted ++;
}
} else {