Skip to content

Commit

Permalink
use filesize
Browse files Browse the repository at this point in the history
  • Loading branch information
Ughuuu committed Dec 5, 2024
1 parent 05b782b commit 437070a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
25 changes: 16 additions & 9 deletions editor/export/export_template_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ void ExportTemplateManager::_download_current() {
download_progress_hb->show();

if (mirrors_available) {
String mirror_url = _get_selected_mirror();
String mirror_url = _get_selected_mirror()["url"];
if (mirror_url.is_empty()) {
_set_current_progress_status(TTR("There are no mirrors available."), true);
return;
Expand Down Expand Up @@ -289,7 +289,10 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code,
ERR_CONTINUE(!m.has("url") || !m.has("name"));

mirrors_list->add_item(m["name"]);
mirrors_list->set_item_metadata(i + 1, m["url"]);
Dictionary metadata_dict;
metadata_dict["url"] = m["url"];
metadata_dict["filesize"] = m.get("filesize", -1);
mirrors_list->set_item_metadata(i + 1, metadata_dict);

mirrors_available = true;
}
Expand All @@ -304,7 +307,7 @@ void ExportTemplateManager::_refresh_mirrors_completed(int p_status, int p_code,
is_refreshing_mirrors = false;

if (is_downloading_templates) {
String mirror_url = _get_selected_mirror();
String mirror_url = _get_selected_mirror()["url"];
if (mirror_url.is_empty()) {
_set_current_progress_status(TTR("There are no mirrors available."), true);
return;
Expand Down Expand Up @@ -348,10 +351,14 @@ bool ExportTemplateManager::_humanize_http_status(HTTPRequest *p_request, String
case HTTPClient::STATUS_BODY:
*r_status = TTR("Downloading");
*r_downloaded_bytes = p_request->get_downloaded_bytes();
*r_total_bytes = p_request->get_body_size();
int total_size = _get_selected_mirror()["filesize"];
if (total_size < 0) {
total_size = p_request->get_body_size();
}
*r_total_bytes = total_size;

if (p_request->get_body_size() > 0) {
*r_status += " " + String::humanize_size(p_request->get_downloaded_bytes()) + "/" + String::humanize_size(p_request->get_body_size());
if (total_size > 0) {
*r_status += " " + String::humanize_size(p_request->get_downloaded_bytes()) + "/" + String::humanize_size(total_size);
} else {
*r_status += " " + String::humanize_size(p_request->get_downloaded_bytes());
}
Expand Down Expand Up @@ -580,7 +587,7 @@ void ExportTemplateManager::_uninstall_template_confirmed() {
_update_template_status();
}

String ExportTemplateManager::_get_selected_mirror() const {
Dictionary ExportTemplateManager::_get_selected_mirror() const {
if (mirrors_list->get_item_count() == 1) {
return "";

Check failure on line 592 in editor/export/export_template_manager.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor (target=editor tests=yes)

could not convert '""' from 'const char [1]' to 'Dictionary'

Check failure on line 592 in editor/export/export_template_manager.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor w/ Mono (target=editor)

could not convert '""' from 'const char [1]' to 'Dictionary'

Check failure on line 592 in editor/export/export_template_manager.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with doubles and GCC sanitizers (target=editor, tests=yes, dev_build=yes, scu_build=yes, precision=double, use_asan=yes, use_ubsan=yes, linker=gold)

could not convert '""' from 'const char [1]' to 'Dictionary'

Check failure on line 592 in editor/export/export_template_manager.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)

no viable conversion from returned value of type 'const char [1]' to function return type 'Dictionary'

Check failure on line 592 in editor/export/export_template_manager.cpp

View workflow job for this annotation

GitHub Actions / 🏁 Windows / Editor (target=editor, tests=yes)

'return': cannot convert from 'const char [1]' to 'Dictionary'

Check failure on line 592 in editor/export/export_template_manager.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)

no viable conversion from returned value of type 'const char [1]' to function return type 'Dictionary'
}
Expand All @@ -597,7 +604,7 @@ String ExportTemplateManager::_get_selected_mirror() const {
void ExportTemplateManager::_mirror_options_button_cbk(int p_id) {
switch (p_id) {
case VISIT_WEB_MIRROR: {
String mirror_url = _get_selected_mirror();
String mirror_url = _get_selected_mirror()["url"];
if (mirror_url.is_empty()) {
EditorNode::get_singleton()->show_warning(TTR("There are no mirrors available."));
return;
Expand All @@ -607,7 +614,7 @@ void ExportTemplateManager::_mirror_options_button_cbk(int p_id) {
} break;

case COPY_MIRROR_URL: {
String mirror_url = _get_selected_mirror();
String mirror_url = _get_selected_mirror()["url"];
if (mirror_url.is_empty()) {
EditorNode::get_singleton()->show_warning(TTR("There are no mirrors available."));
return;
Expand Down
2 changes: 1 addition & 1 deletion editor/export/export_template_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class ExportTemplateManager : public AcceptDialog {
void _uninstall_template(const String &p_version);
void _uninstall_template_confirmed();

String _get_selected_mirror() const;
Dictionary _get_selected_mirror() const;
void _mirror_options_button_cbk(int p_id);
void _installed_table_button_cbk(Object *p_item, int p_column, int p_id, MouseButton p_button);

Expand Down

0 comments on commit 437070a

Please sign in to comment.