| 375 | } |
| 376 | |
| 377 | Error PluginManager::populate_plugin_version_hashes(PluginVersion &plugin_version) { |
| 378 | auto temp_folder = GDRESettings::get_singleton()->get_gdre_tmp_path(); |
| 379 | String url = plugin_version.release_info.download_url; |
| 380 | String new_temp_foldr = temp_folder.path_join(plugin_version.release_info.plugin_source + "_" + itos(plugin_version.release_info.primary_id) + "_" + itos(plugin_version.release_info.secondary_id)); |
| 381 | String zip_name = gdre::remove_url_query_params(url).get_file(); |
| 382 | if (zip_name.is_empty()) { |
| 383 | String ext = "zip"; |
| 384 | if (auto pos = url.find(".tar"); pos != -1) { |
| 385 | ext = url.substr(pos); |
| 386 | } |
| 387 | zip_name = vformat("plugin.%s", ext); |
| 388 | } |
| 389 | String zip_path = new_temp_foldr.path_join(zip_name); |
| 390 | print_line("Downloading plugin to populate cache: " + url); |
| 391 | |
| 392 | Error err = OK; |
| 393 | if (!is_prepopping()) { |
| 394 | auto task_id = TaskManager::get_singleton()->add_download_task(url, zip_path); |
| 395 | err = TaskManager::get_singleton()->wait_for_download_task_completion(task_id); |
| 396 | } else { |
| 397 | err = gdre::download_file_sync(url, zip_path); |
| 398 | } |
| 399 | |
| 400 | if (err) { |
| 401 | if (err == ERR_FILE_NOT_FOUND) { |
| 402 | ERR_FAIL_V_MSG(err, "Failed plugin download (404): " + url); |
| 403 | } else if (err == ERR_UNAUTHORIZED) { |
| 404 | ERR_FAIL_V_MSG(err, "Failed plugin download (401): " + url); |
| 405 | } |
| 406 | return err; |
| 407 | } |
| 408 | |
| 409 | plugin_version.size = FileAccess::get_size(zip_path); |
| 410 | ERR_FAIL_COND_V_MSG(!gdre::is_path_archive(zip_path), ERR_FILE_CORRUPT, "File is not an archive: " + zip_path); |
| 411 | |
| 412 | auto close_and_remove_zip = [&]() { |
| 413 | gdre::rimraf(zip_path); |
| 414 | }; |
| 415 | |
| 416 | // just unzup the files to the |
| 417 | String unzupped_path = new_temp_foldr.path_join("unzipped"); |
| 418 | err = gdre::unzip_file_to_dir(zip_path, unzupped_path); |
| 419 | if (err) { |
| 420 | close_and_remove_zip(); |
| 421 | return err; |
| 422 | } |
| 423 | |
| 424 | auto files = gdre::get_recursive_dir_list(unzupped_path, {}, false, true); |
| 425 | for (int64_t i = files.size() - 1; i >= 0; i--) { |
| 426 | if (files[i].simplify_path().begins_with("__MACOSX")) { |
| 427 | files.remove_at(i); |
| 428 | } |
| 429 | } |
| 430 | String gd_ext_file = ""; |
| 431 | Ref<DirAccess> da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); |
| 432 | |
| 433 | // get all the gdexts |
| 434 | HashMap<String, GDExtInfo> gdexts; |
nothing calls this directly
no test coverage detected