diff --git a/code/components/jomjol_fileserver_ota/server_file.cpp b/code/components/jomjol_fileserver_ota/server_file.cpp index 137aeb5f..df396800 100644 --- a/code/components/jomjol_fileserver_ota/server_file.cpp +++ b/code/components/jomjol_fileserver_ota/server_file.cpp @@ -61,7 +61,7 @@ struct file_server_data { using namespace std; -string SUFFIX_ZW = "_0xge"; +string SUFFIX_ZW = "_tmp"; static esp_err_t send_logfile(httpd_req_t *req, bool send_full_file); static esp_err_t send_datafile(httpd_req_t *req, bool send_full_file); @@ -911,7 +911,7 @@ void delete_all_in_directory(std::string _directory) closedir(dir); } -std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::string _target_bin, std::string _main, bool _initial_setup) +std::string unzip_new(std::string _in_zip_file, std::string _html_tmp, std::string _html_final, std::string _target_bin, std::string _main, bool _initial_setup) { int i, sort_iter; mz_bool status; @@ -993,10 +993,15 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st } else { - zw = _target_zip + zw; + zw = _html_tmp + zw; } } + + // files in the html folder shall be redirected to the temporary html folder + if (zw.find(_html_final) == 0) { + FindReplace(zw, _html_final, _html_tmp); + } string filename_zw = zw + SUFFIX_ZW; diff --git a/code/components/jomjol_fileserver_ota/server_file.h b/code/components/jomjol_fileserver_ota/server_file.h index cae83512..3520ae5d 100644 --- a/code/components/jomjol_fileserver_ota/server_file.h +++ b/code/components/jomjol_fileserver_ota/server_file.h @@ -9,7 +9,7 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path); void unzip(std::string _in_zip_file, std::string _target_directory); -std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::string _target_bin, std::string _main = "/sdcard/", bool _initial_setup = false); +std::string unzip_new(std::string _in_zip_file, std::string _html_tmp, std::string _html_final, std::string _target_bin, std::string _main = "/sdcard/", bool _initial_setup = false); void delete_all_in_directory(std::string _directory); diff --git a/code/components/jomjol_fileserver_ota/server_ota.cpp b/code/components/jomjol_fileserver_ota/server_ota.cpp index 263dc1aa..02c55d67 100644 --- a/code/components/jomjol_fileserver_ota/server_ota.cpp +++ b/code/components/jomjol_fileserver_ota/server_ota.cpp @@ -87,7 +87,7 @@ void task_do_Update_ZIP(void *pvParameter) /* Extract the ZIP file. The content of the html folder gets extracted to the temporar folder html-temp. */ LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Extracting ZIP file '" + _file_name_update + "'..."); - retfirmware = unzip_new(_file_name_update, outHtmlTmp+"/", outbin+"/", "/sdcard/", initial_setup); + retfirmware = unzip_new(_file_name_update, outHtmlTmp+"/", outHtml+"/", outbin+"/", "/sdcard/", initial_setup); LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Files unzipped."); /* ZIP file got extracted, replace the old html folder with the new one */