download templates to a file using separate thread
(cherry picked from commit b4f1a035e3
)
This commit is contained in:
parent
069658f1be
commit
e6252bda5e
|
@ -400,20 +400,11 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int
|
||||||
if (p_code != 200) {
|
if (p_code != 200) {
|
||||||
template_list_state->set_text(TTR("Failed:") + " " + itos(p_code));
|
template_list_state->set_text(TTR("Failed:") + " " + itos(p_code));
|
||||||
} else {
|
} else {
|
||||||
String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz");
|
String path = download_templates->get_download_file();
|
||||||
FileAccess *f = FileAccess::open(path, FileAccess::WRITE);
|
|
||||||
if (!f) {
|
|
||||||
template_list_state->set_text(TTR("Can't write file."));
|
|
||||||
} else {
|
|
||||||
int size = p_data.size();
|
|
||||||
PoolVector<uint8_t>::Read r = p_data.read();
|
|
||||||
f->store_buffer(r.ptr(), size);
|
|
||||||
memdelete(f);
|
|
||||||
template_list_state->set_text(TTR("Download Complete."));
|
template_list_state->set_text(TTR("Download Complete."));
|
||||||
template_downloader->hide();
|
template_downloader->hide();
|
||||||
_install_from_file(path, false);
|
_install_from_file(path, false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -430,6 +421,8 @@ void ExportTemplateManager::_begin_template_download(const String &p_url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
download_data.clear();
|
download_data.clear();
|
||||||
|
download_templates->set_download_file(EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz"));
|
||||||
|
download_templates->set_use_threads(true);
|
||||||
|
|
||||||
Error err = download_templates->request(p_url);
|
Error err = download_templates->request(p_url);
|
||||||
if (err != OK) {
|
if (err != OK) {
|
||||||
|
|
Loading…
Reference in New Issue