mirror of
https://github.com/godotengine/godot.git
synced 2025-10-21 17:03:42 +00:00
Narrow FileAccess scope to prevent deadlocks.
This commit is contained in:
parent
5974e1432e
commit
4bf99f4af2
29 changed files with 511 additions and 459 deletions
|
@ -81,12 +81,14 @@ void JavaScriptToolsEditorPlugin::_download_zip(Variant p_v) {
|
|||
const String base_path = resource_path.substr(0, resource_path.rfind("/")) + "/";
|
||||
_zip_recursive(resource_path, base_path, zip);
|
||||
zipClose(zip, nullptr);
|
||||
Ref<FileAccess> f = FileAccess::open(output_path, FileAccess::READ);
|
||||
ERR_FAIL_COND_MSG(f.is_null(), "Unable to create ZIP file.");
|
||||
Vector<uint8_t> buf;
|
||||
buf.resize(f->get_length());
|
||||
f->get_buffer(buf.ptrw(), buf.size());
|
||||
godot_js_os_download_buffer(buf.ptr(), buf.size(), output_name.utf8().get_data(), "application/zip");
|
||||
{
|
||||
Ref<FileAccess> f = FileAccess::open(output_path, FileAccess::READ);
|
||||
ERR_FAIL_COND_MSG(f.is_null(), "Unable to create ZIP file.");
|
||||
Vector<uint8_t> buf;
|
||||
buf.resize(f->get_length());
|
||||
f->get_buffer(buf.ptrw(), buf.size());
|
||||
godot_js_os_download_buffer(buf.ptr(), buf.size(), output_name.utf8().get_data(), "application/zip");
|
||||
}
|
||||
|
||||
// Remove the temporary file since it was sent to the user's native filesystem as a download.
|
||||
DirAccess::remove_file_or_error(output_path);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue