From 146eb6654d421c82a14b6ec2e0e3357be199eaf5 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 4 Sep 2020 12:49:57 +0200 Subject: [PATCH] Refactor gui upload --- tasmota/xdrv_01_webserver.ino | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tasmota/xdrv_01_webserver.ino b/tasmota/xdrv_01_webserver.ino index dc50e68e1..ed15c9e12 100644 --- a/tasmota/xdrv_01_webserver.ino +++ b/tasmota/xdrv_01_webserver.ino @@ -2712,6 +2712,7 @@ void HandleUploadLoop(void) HTTPUpload& upload = Webserver->upload(); + // ***** Step1: Start upload file if (UPLOAD_FILE_START == upload.status) { restart_flag = 60; if (0 == upload.filename.c_str()[0]) { @@ -2752,7 +2753,10 @@ void HandleUploadLoop(void) } } Web.upload_progress_dot_count = 0; - } else if (!Web.upload_error && (UPLOAD_FILE_WRITE == upload.status)) { + } + + // ***** Step2: Write upload file + else if (!Web.upload_error && (UPLOAD_FILE_WRITE == upload.status)) { if (0 == upload.totalSize) { if (UPL_SETTINGS == Web.upload_file_type) { Web.config_block_count = 0; @@ -2803,6 +2807,7 @@ void HandleUploadLoop(void) // upload.buf[2] = 3; // Force DOUT - ESP8285 } } + AddLog_P2(LOG_LEVEL_DEBUG, PSTR(D_LOG_UPLOAD "File type %d"), Web.upload_file_type); } } if (UPL_SETTINGS == Web.upload_file_type) { @@ -2874,7 +2879,10 @@ void HandleUploadLoop(void) if (!(Web.upload_progress_dot_count % 80)) { Serial.println(); } } } - } else if(!Web.upload_error && (UPLOAD_FILE_END == upload.status)) { + } + + // ***** Step3: Finish upload file + else if(!Web.upload_error && (UPLOAD_FILE_END == upload.status)) { if (_serialoutput && (Web.upload_progress_dot_count % 80)) { Serial.println(); } @@ -2950,9 +2958,12 @@ void HandleUploadLoop(void) } } if (!Web.upload_error) { - AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes. " D_RESTARTING), upload.totalSize); + AddLog_P2(LOG_LEVEL_INFO, PSTR(D_LOG_UPLOAD D_SUCCESSFUL " %u bytes"), upload.totalSize); } - } else if (UPLOAD_FILE_ABORTED == upload.status) { + } + + // ***** Step4: Abort upload file + else if (UPLOAD_FILE_ABORTED == upload.status) { restart_flag = 0; MqttRetryCounter(0); #ifdef USE_COUNTER