X-Git-Url: https://glassweightruler.freedombox.rocks/gitweb/Ventoy.git/blobdiff_plain/bf797ceadbc70f004bcb0ea463ca568f1e622bfe..9b7d6cbc3dc75d0d5fe998f57195e7c39dd0fcd4:/Plugson/src/Web/ventoy_http.c diff --git a/Plugson/src/Web/ventoy_http.c b/Plugson/src/Web/ventoy_http.c index 6de2159..aa1d87d 100644 --- a/Plugson/src/Web/ventoy_http.c +++ b/Plugson/src/Web/ventoy_http.c @@ -918,9 +918,11 @@ static int ventoy_api_theme_add_file(struct mg_connection *conn, VTOY_JSON *json int ret; int index = 0; const char *path = NULL; + const char *realpath = NULL; path_node *node = NULL; path_node *cur = NULL; data_theme *data = NULL; + char pathbuf[MAX_PATH]; vtoy_json_get_int(json, "index", &index); data = g_data_theme + index; @@ -928,6 +930,19 @@ static int ventoy_api_theme_add_file(struct mg_connection *conn, VTOY_JSON *json path = VTOY_JSON_STR_EX("path"); if (path) { + realpath = ventoy_real_path(path); + scnprintf(pathbuf, sizeof(pathbuf), "%s", realpath); + + for (node = data->filelist; node; node = node->next) + { + realpath = ventoy_real_path(node->path); + if (strcmp(pathbuf, realpath) == 0) + { + ventoy_json_result(conn, VTOY_JSON_DUPLICATE); + return 0; + } + } + node = zalloc(sizeof(path_node)); if (node) { @@ -980,16 +995,31 @@ static int ventoy_api_theme_add_font(struct mg_connection *conn, VTOY_JSON *json int ret; int index = 0; const char *path = NULL; + const char *realpath = NULL; path_node *node = NULL; path_node *cur = NULL; data_theme *data = NULL; - + char pathbuf[MAX_PATH]; + vtoy_json_get_int(json, "index", &index); data = g_data_theme + index; path = VTOY_JSON_STR_EX("path"); if (path) { + realpath = ventoy_real_path(path); + scnprintf(pathbuf, sizeof(pathbuf), "%s", realpath); + + for (node = data->fontslist; node; node = node->next) + { + realpath = ventoy_real_path(node->path); + if (strcmp(pathbuf, realpath) == 0) + { + ventoy_json_result(conn, VTOY_JSON_DUPLICATE); + return 0; + } + } + node = zalloc(sizeof(path_node)); if (node) {