From 9fbb16a5dbdc4dd4d66167c69c3d7c20d409b354 Mon Sep 17 00:00:00 2001 From: bogd Date: Thu, 7 Dec 2023 13:30:19 +0200 Subject: [PATCH] overwrite files in storage partition, cron log file switche off --- include/SystemApplication.h | 2 +- src/CronTimers.c | 2 +- src/FileServer.c | 21 ++++++++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/include/SystemApplication.h b/include/SystemApplication.h index b30bda4..b49293c 100644 --- a/include/SystemApplication.h +++ b/include/SystemApplication.h @@ -30,7 +30,7 @@ #define REAST_API_DEBUG_MODE 0 -#define EXPECTED_MAX_DATA_SIZE (4096 + 2048) +#define EXPECTED_MAX_DATA_SIZE (4096 * 2) #define VAR_MAX_NAME_LENGTH (32) #define VAR_MAX_VALUE_LENGTH (EXPECTED_MAX_DATA_SIZE - 512) diff --git a/src/CronTimers.c b/src/CronTimers.c index 714c63e..2c1511b 100644 --- a/src/CronTimers.c +++ b/src/CronTimers.c @@ -108,7 +108,7 @@ void TimeObtainHandler(struct timeval *tm) ReloadCronSheduler(); ExecuteLastAction(GetSystemObjects()); ExecuteLastAction(GetCustomObjects()); - LogFile("cron.log", "Cron service started"); + } void DebugTimer() diff --git a/src/FileServer.c b/src/FileServer.c index 0fa2214..3f1918b 100644 --- a/src/FileServer.c +++ b/src/FileServer.c @@ -329,13 +329,7 @@ esp_err_t upload_post_handler(httpd_req_t *req) return ESP_FAIL; } - if (stat(filepath, &file_stat) == 0) - { - ESP_LOGE(TAG, "File already exists : %s", filepath); - /* Respond with 400 Bad Request */ - httpd_resp_send_err(req, HTTPD_400_BAD_REQUEST, "File already exists"); - return ESP_FAIL; - } + /* File cannot be larger than a limit */ if (req->content_len > MAX_FILE_SIZE) @@ -350,6 +344,19 @@ esp_err_t upload_post_handler(httpd_req_t *req) return ESP_FAIL; } + if (stat(filepath, &file_stat) == 0) + { + + + ESP_LOGW(TAG, "File already exists : %s", filepath); + /* Respond with 400 Bad Request */ + //httpd_resp_send_err(req, HTTPD_400_BAD_REQUEST, "File already exists"); + //return ESP_FAIL; + unlink(filepath); + + } + + fd = fopen(filepath, "w"); if (!fd) {