diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index a30f616c61..b33fac227c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1256,10 +1256,20 @@ static int action_ok_download_generic(const char *path, char s2[PATH_MAX_LENGTH] = {0}; settings_t *settings = config_get_ptr(); - fill_pathname_join(s, settings->network.buildbot_url, - path, sizeof(s)); + if (!strcmp(type_msg, "cb_update_assets")) + { + path = "assets.zip"; + fill_pathname_join(s, settings->network.buildbot_assets_url, + "frontend/assets.zip", sizeof(s)); + } + else + { + fill_pathname_join(s, settings->network.buildbot_url, + path, sizeof(s)); + } strlcpy(core_updater_path, path, sizeof(core_updater_path)); + snprintf(s2, sizeof(s2), "%s %s.", menu_hash_to_str(MENU_LABEL_VALUE_STARTING_DOWNLOAD), @@ -1283,6 +1293,16 @@ static int action_ok_core_updater_download(const char *path, return 0; } +static int action_ok_update_assets(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ +#ifdef HAVE_NETWORKING + action_ok_download_generic(path, label, type, idx, entry_idx, + "cb_update_assets"); +#endif + return 0; +} + static int action_ok_disk_cycle_tray_status(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -1653,6 +1673,9 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_SCREEN_RESOLUTION: cbs->action_ok = action_ok_video_resolution; break; + case MENU_LABEL_UPDATE_ASSETS: + cbs->action_ok = action_ok_update_assets; + break; default: return -1; } diff --git a/tasks/task_http.c b/tasks/task_http.c index c6ce003ecb..f003ea9f1f 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -28,6 +28,7 @@ #define CB_CORE_UPDATER_DOWNLOAD 0x7412da7dU #define CB_CORE_UPDATER_LIST 0x32fd4f01U +#define CB_UPDATE_ASSETS 0xbf85795eU extern char core_updater_path[PATH_MAX_LENGTH]; @@ -119,6 +120,48 @@ static int cb_core_updater_download(void *data, size_t len) return 0; } +static int cb_update_assets(void *data, size_t len) +{ + const char *file_ext = NULL; + char output_path[PATH_MAX_LENGTH] = {0}; + char msg[PATH_MAX_LENGTH] = {0}; + settings_t *settings = config_get_ptr(); + + if (!data) + return -1; + + fill_pathname_join(output_path, settings->assets_directory, + core_updater_path, sizeof(output_path)); + + if (!write_file(output_path, data, len)) + return -1; + + snprintf(msg, sizeof(msg), "Download complete: %s.", + core_updater_path); + + rarch_main_msg_queue_push(msg, 1, 90, true); + +#ifdef HAVE_ZLIB + file_ext = path_get_extension(output_path); + + if (!settings->network.buildbot_auto_extract_archive) + return 0; + + if (!strcasecmp(file_ext,"zip")) + { + if (!zlib_parse_file(output_path, NULL, zlib_extract_core_callback, + + (void*)settings->assets_directory)) + RARCH_LOG("Could not process ZIP file.\n"); + + if (path_file_exists(output_path)) + remove(output_path); + } +#endif + + return 0; +} + static int rarch_main_data_http_con_iterate_transfer(http_handle_t *http) { if (!net_http_connection_iterate(http->connection.handle)) @@ -187,6 +230,9 @@ static int cb_http_conn_default(void *data_, size_t len) case CB_CORE_UPDATER_LIST: http->cb = &cb_core_updater_list; break; + case CB_UPDATE_ASSETS: + http->cb = &cb_update_assets; + break; } }