Ver Fonte

Bugfix Double Extract ZIP-Files

jomjol há 3 anos atrás
pai
commit
07913045e2

+ 5 - 1
code/components/jomjol_fileserver_ota/server_file.cpp

@@ -935,7 +935,11 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
 
 
     // Get and print information about each file in the archive.
     // Get and print information about each file in the archive.
     int numberoffiles = (int)mz_zip_reader_get_num_files(&zip_archive);
     int numberoffiles = (int)mz_zip_reader_get_num_files(&zip_archive);
-    for (sort_iter = 0; sort_iter < 2; sort_iter++)
+    ESP_LOGI(TAG, "Numbers of files to be extrated: %d", numberoffiles);
+
+
+    sort_iter = 0;
+//    for (sort_iter = 0; sort_iter < 2; sort_iter++)
     {
     {
         memset(&zip_archive, 0, sizeof(zip_archive));
         memset(&zip_archive, 0, sizeof(zip_archive));
         status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);
         status = mz_zip_reader_init_file(&zip_archive, _in_zip_file.c_str(), sort_iter ? MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY : 0);

+ 15 - 15
code/components/jomjol_fileserver_ota/server_ota.cpp

@@ -58,6 +58,18 @@ esp_err_t handler_reboot(httpd_req_t *req);
 std::string _file_name_update;
 std::string _file_name_update;
 
 
 
 
+
+static void infinite_loop(void)
+{
+    int i = 0;
+    ESP_LOGI(TAG, "When a new firmware is available on the server, press the reset button to download it");
+    while(1) {
+        ESP_LOGI(TAG, "Waiting for a new firmware... %d", ++i);
+        vTaskDelay(1000 / portTICK_PERIOD_MS);
+    }
+}
+
+
 void task_do_Update_ZIP(void *pvParameter)
 void task_do_Update_ZIP(void *pvParameter)
 {
 {
     std::string filetype = toUpper(getFileType(_file_name_update));
     std::string filetype = toUpper(getFileType(_file_name_update));
@@ -110,26 +122,14 @@ void CheckUpdate()
     BaseType_t xReturned;
     BaseType_t xReturned;
     int _i = configMINIMAL_STACK_SIZE;
     int _i = configMINIMAL_STACK_SIZE;
     xReturned = xTaskCreate(&task_do_Update_ZIP, "task_do_Update_ZIP", configMINIMAL_STACK_SIZE * 35, NULL, tskIDLE_PRIORITY+1, NULL);
     xReturned = xTaskCreate(&task_do_Update_ZIP, "task_do_Update_ZIP", configMINIMAL_STACK_SIZE * 35, NULL, tskIDLE_PRIORITY+1, NULL);
-    TickType_t xDelay;
-    xDelay = 2000000 / portTICK_PERIOD_MS;
-    ESP_LOGD(TAG, "Wait for Update to be finished: sleep for: %ldms", (long) xDelay);
-    vTaskDelay( xDelay );   
-}
-
-
-
-static void infinite_loop(void)
-{
-    int i = 0;
-    ESP_LOGI(TAG, "When a new firmware is available on the server, press the reset button to download it");
-    while(1) {
-        ESP_LOGI(TAG, "Waiting for a new firmware... %d", ++i);
-        vTaskDelay(2000 / portTICK_PERIOD_MS);
+    while(1) { // wait until reboot within task_do_Update_ZIP
+        vTaskDelay(1000 / portTICK_PERIOD_MS);
     }
     }
 }
 }
 
 
 
 
 
 
+
 static bool ota_update_task(std::string fn)
 static bool ota_update_task(std::string fn)
 {
 {
     esp_err_t err;
     esp_err_t err;