]> glassweightruler.freedombox.rocks Git - Ventoy.git/commitdiff
Add tip in Plugson web page when old ventoy.json contains invalid configuration.
authorlongpanda <admin@ventoy.net>
Sun, 6 Feb 2022 10:00:29 +0000 (18:00 +0800)
committerlongpanda <admin@ventoy.net>
Sun, 6 Feb 2022 10:00:29 +0000 (18:00 +0800)
Plugson/src/Core/ventoy_util.h
Plugson/src/Web/ventoy_http.c
Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe
Plugson/www/index.html
Plugson/www/static/js/vtoy.js

index 5866c0b83b6437a140fcd6abedf68ef2e88b8b96..357dcccacde7b648decc9166774ba0b2e31125d3 100644 (file)
@@ -87,6 +87,7 @@ typedef struct SYSINFO
 {
     char buildtime[128];
     int syntax_error;
 {
     char buildtime[128];
     int syntax_error;
+    int invalid_config;
         
     int language;
     int pathcase;
         
     int language;
     int pathcase;
index 96a6fa51589930db652db33ac674371b74659dfe..be24e3755f5397997d00b7d58c5d83c4edd7d11b 100644 (file)
@@ -322,6 +322,9 @@ static int ventoy_api_sysinfo(struct mg_connection *conn, VTOY_JSON *json)
     //read clear
     VTOY_JSON_FMT_SINT("syntax_error", g_sysinfo.syntax_error);
     g_sysinfo.syntax_error = 0;
     //read clear
     VTOY_JSON_FMT_SINT("syntax_error", g_sysinfo.syntax_error);
     g_sysinfo.syntax_error = 0;
+    
+    VTOY_JSON_FMT_SINT("invalid_config", g_sysinfo.invalid_config);
+    g_sysinfo.invalid_config = 0;
 
 
     #if defined(_MSC_VER) || defined(WIN32)
 
 
     #if defined(_MSC_VER) || defined(WIN32)
@@ -4917,6 +4920,7 @@ static int ventoy_load_old_json(const char *filename)
     unsigned char *start = NULL;
     VTOY_JSON *json = NULL;
     VTOY_JSON *node = NULL;
     unsigned char *start = NULL;
     VTOY_JSON *json = NULL;
     VTOY_JSON *node = NULL;
+    VTOY_JSON *next = NULL;
 
     ret = ventoy_read_file_to_buf(filename, 4, (void **)&buffer, &buflen);
     if (ret)
 
     ret = ventoy_read_file_to_buf(filename, 4, (void **)&buffer, &buflen);
     if (ret)
@@ -4950,6 +4954,18 @@ static int ventoy_load_old_json(const char *filename)
     {
         vlog("parse ventoy.json success\n");
 
     {
         vlog("parse ventoy.json success\n");
 
+        for (node = json->pstChild; node; node = node->pstNext)
+        for (next = node->pstNext; next; next = next->pstNext)
+        {
+            if (node->pcName && next->pcName && strcmp(node->pcName, next->pcName) == 0)
+            {
+                vlog("ventoy.json contains duplicate key <%s>.\n", node->pcName);
+                g_sysinfo.invalid_config = 1;
+                ret = 1;
+                goto end;
+            }
+        }
+
         for (node = json->pstChild; node; node = node->pstNext)
         {
             ventoy_parse_json(control);
         for (node = json->pstChild; node; node = node->pstNext)
         {
             ventoy_parse_json(control);
@@ -4975,6 +4991,7 @@ static int ventoy_load_old_json(const char *filename)
         ret = 1;
     }
 
         ret = 1;
     }
 
+end:
     vtoy_json_destroy(json);
 
     free(buffer);
     vtoy_json_destroy(json);
 
     free(buffer);
index 8efd516bf621c5e6703bff95d994bfed8873cdc0..21fcdbac29627c5cc33e704b12a6326ee444a2f6 100644 (file)
Binary files a/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe and b/Plugson/vs/VentoyPlugson/Release/VentoyPlugson.exe differ
index 45731a0c594a9b3594eaeaa06dbf1a6ea86f36ec..9037a94770a06851fe3939fd1578c4301169b540 100644 (file)
 \r
         <footer class="main-footer">\r
             <div class="pull-right hidden-xs">\r
 \r
         <footer class="main-footer">\r
             <div class="pull-right hidden-xs">\r
-                <b id="plugson_build_date">20220108 22:41:02</b>
+                <b id="plugson_build_date">20220204 16:31:23</b>
             </div>\r
             <strong><a href="https://www.ventoy.net" target="_blank">https://www.ventoy.net</a></strong>\r
         </footer>\r
             </div>\r
             <strong><a href="https://www.ventoy.net" target="_blank">https://www.ventoy.net</a></strong>\r
         </footer>\r
 \r
     //Main process\r
     var m_syntax_error;\r
 \r
     //Main process\r
     var m_syntax_error;\r
+    var m_invalid_config;\r
     callVtoySync({\r
         method : 'sysinfo'\r
     }, function(data) {\r
     callVtoySync({\r
         method : 'sysinfo'\r
     }, function(data) {\r
         g_current_dir = data.curdir;\r
         g_current_os = data.os;\r
         m_syntax_error = data.syntax_error;\r
         g_current_dir = data.curdir;\r
         g_current_os = data.os;\r
         m_syntax_error = data.syntax_error;\r
+        m_invalid_config = data.invalid_config;\r
 \r
         \r
 \r
 \r
         \r
 \r
                 });\r
                 m_syntax_error = 0;\r
             }\r
                 });\r
                 m_syntax_error = 0;\r
             }\r
+            \r
+            if (m_invalid_config === 1 && typeof(Modal) === 'object') {\r
+                var title = g_current_language == 'en' ? g_vtoy_cur_language_en.STR_INFO : g_vtoy_cur_language_cn.STR_INFO;\r
+                var msg = g_current_language == 'en' ? g_vtoy_cur_language_en.STR_INVALID_CONFIG_TIP : g_vtoy_cur_language_cn.STR_INVALID_CONFIG_TIP;\r
+                Modal.alert({title:title,msg:msg}).on(function(e) {\r
+                });\r
+                m_invalid_config = 0;\r
+            }\r
 \r
             setTimeout(function() {\r
                 ventoy_handshake();\r
 \r
             setTimeout(function() {\r
                 ventoy_handshake();\r
index cbffd04aa31e76df104fb79f009a4ae6831154ba..21f71b43c4ef32745e865fe2cf509fc722477872 100644 (file)
@@ -479,6 +479,7 @@ var g_vtoy_cur_language_en =
     "STR_SECURE_BOOT_ENABLE": "Enable",\r
     "STR_SECURE_BOOT_DISABLE": "Disable",\r
     "STR_SYNTAX_ERROR_TIP": "Syntax error detected in ventoy.json, so the configuration is not loaded!",\r
     "STR_SECURE_BOOT_ENABLE": "Enable",\r
     "STR_SECURE_BOOT_DISABLE": "Disable",\r
     "STR_SYNTAX_ERROR_TIP": "Syntax error detected in ventoy.json, so the configuration is not loaded!",\r
+    "STR_INVALID_CONFIG_TIP": "Invalid configuration detected in ventoy.json, so the configuration is not loaded!",\r
 \r
     "STR_XXX": "xxx"\r
 };\r
 \r
     "STR_XXX": "xxx"\r
 };\r
@@ -613,6 +614,7 @@ var g_vtoy_cur_language_cn =
     "STR_SECURE_BOOT_ENABLE": "开启",\r
     "STR_SECURE_BOOT_DISABLE": "未开启",\r
     "STR_SYNTAX_ERROR_TIP": "ventoy.json 文件中存在语法错误,配置未加载!",\r
     "STR_SECURE_BOOT_ENABLE": "开启",\r
     "STR_SECURE_BOOT_DISABLE": "未开启",\r
     "STR_SYNTAX_ERROR_TIP": "ventoy.json 文件中存在语法错误,配置未加载!",\r
+    "STR_INVALID_CONFIG_TIP": "ventoy.json 文件中存在错误配置,配置未加载!",\r
 \r
 \r
 \r
 \r
 \r
 \r