Explorar o código

Rolling 20220910

jomjol %!s(int64=3) %!d(string=hai) anos
pai
achega
2445377d0a

+ 2 - 12
code/components/jomjol_fileserver_ota/server_file.cpp

@@ -769,8 +769,9 @@ std::string unzip_new(std::string _in_zip_file, std::string _target_zip, std::st
             {
                 zw = _target_zip + zw;
             }
-                
+
             printf("Filename to extract: %s", zw.c_str());
+            DeleteFile(zw);
             FILE* fpTargetFile = OpenFileAndWait(zw.c_str(), "wb");
             fwrite(p, 1, (uint)uncomp_size, fpTargetFile);
             fclose(fpTargetFile);
@@ -934,15 +935,4 @@ void register_server_file_uri(httpd_handle_t server, const char *base_path)
     };
     httpd_register_uri_handler(server, &file_delete);
 
-
-    /* URI handler for getting tflite files from server */
-/*
-    httpd_uri_t file_tflite = {
-        .uri       = "/tflite",   // Match all URIs of type /delete/path/to/file
-        .method    = HTTP_GET,
-        .handler   = get_tflite_file_handler,
-        .user_ctx  = server_data    // Pass server data as context
-    };
-    httpd_register_uri_handler(server, &file_tflite);
-*/
 }

+ 6 - 5
code/components/jomjol_fileserver_ota/server_ota.cpp

@@ -308,7 +308,7 @@ esp_err_t handler_ota_update(httpd_req_t *req)
         
         if (httpd_query_key_value(_query, "task", _valuechar, 30) == ESP_OK)
         {
-            printf("task is found"); printf(_valuechar); printf("\n"); 
+            printf("task is found: "); printf(_valuechar); printf("\n"); 
             _task = std::string(_valuechar);
         }
 
@@ -340,7 +340,8 @@ esp_err_t handler_ota_update(httpd_req_t *req)
 
         if ((filetype == "TFLITE") || (filetype == "TFL"))
         {
-            std::string out = "/sdcard/firmware/" + getFileFullFileName(fn);
+            std::string out = "/sdcard/config/" + getFileFullFileName(fn);
+            DeleteFile(out);
             CopyFile(fn, out);
             DeleteFile(fn);
 
@@ -355,13 +356,13 @@ esp_err_t handler_ota_update(httpd_req_t *req)
         {
             std::string in, out, outbin, zw, retfirmware;
 
-            in = "/sdcard/firmware/html.zip";
+//            in = "/sdcard/firmware/html.zip";
             out = "/sdcard/html";
             outbin = "/sdcard/firmware";
 
-            delete_all_in_directory(out);
+//            delete_all_in_directory(out);
 
-            retfirmware = unzip_new(in, out+"/", outbin+"/");
+            retfirmware = unzip_new(fn, out+"/", outbin+"/");
 
             if (retfirmware.length() > 0)
             {

+ 13 - 2
code/components/jomjol_helper/Helper.cpp

@@ -213,6 +213,14 @@ void DeleteFile(string fn)
 {
 //	ESP_LOGI(logTag, "Deleting file : %s", fn.c_str());
 	/* Delete file */
+	FILE* fpSourceFile = OpenFileAndWait(fn.c_str(), "rb");
+	if (!fpSourceFile)	// Sourcefile existiert nicht sonst gibt es einen Fehler beim Kopierversuch!
+	{
+		printf("DeleteFile: File %s existiert nicht!\n", fn.c_str());
+		return;
+	}
+	fclose(fpSourceFile);
+
 	unlink(fn.c_str());    
 }
 
@@ -250,17 +258,20 @@ void CopyFile(string input, string output)
 	// Close The Files
 	fclose(fpSourceFile);
 	fclose(fpTargetFile);
+	printf("File copied: %s to %s", input.c_str(), output.c_str());
 }
 
 string getFileFullFileName(string filename)
 {
-	size_t lastpos = filename.find_last_of("/", 0);
+	size_t lastpos = filename.find_last_of('/');
 
 	if (lastpos == string::npos)
 		return "";
 
+	printf("Last position: %d\n", lastpos);
+
 	string zw = filename.substr(lastpos + 1, filename.size() - lastpos);
-	zw = toUpper(zw);
+//	zw = toUpper(zw);
 
 	return zw;
 }

+ 1 - 1
code/main/version.cpp

@@ -1,4 +1,4 @@
 const char* GIT_REV="N/A";
 const char* GIT_TAG="N/A";
 const char* GIT_BRANCH="N/A";
-const char* BUILD_TIME="2022-09-10 20:02";
+const char* BUILD_TIME="2022-09-10 20:27";

+ 1 - 1
code/version.cpp

@@ -1,4 +1,4 @@
 const char* GIT_REV="N/A";
 const char* GIT_TAG="N/A";
 const char* GIT_BRANCH="N/A";
-const char* BUILD_TIME="2022-09-10 20:02";
+const char* BUILD_TIME="2022-09-10 20:27";