1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-09 12:50:35 +00:00

Redo how the remote filesystem works

Instead of reading files over the network, the new version uses a local file cache and only updates files when it changes.

The original remote filesystem was created 14 years ago, when ethernet was faster than hard drives or even flash. Also, mobile devices have a very small amount of storage.
Nowadays, this is no longer the case so the approach is changed to using a persistent cache in the target device.

Co-authored-by: m4gr3d
This commit is contained in:
Juan Linietsky
2023-04-28 13:15:36 +02:00
parent 352ebe9725
commit 273a6eeb66
22 changed files with 714 additions and 1039 deletions

View File

@@ -41,7 +41,6 @@
#include "core/input/input.h"
#include "core/input/input_map.h"
#include "core/io/dir_access.h"
#include "core/io/file_access_network.h"
#include "core/io/file_access_pack.h"
#include "core/io/file_access_zip.h"
#include "core/io/image_loader.h"
@@ -129,7 +128,6 @@ static Time *time_singleton = nullptr;
#ifdef MINIZIP_ENABLED
static ZipArchive *zip_packed_data = nullptr;
#endif
static FileAccessNetworkClient *file_access_network_client = nullptr;
static MessageQueue *message_queue = nullptr;
// Initialized in setup2()
@@ -1384,9 +1382,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
// Network file system needs to be configured before globals, since globals are based on the
// 'project.godot' file which will only be available through the network if this is enabled
FileAccessNetwork::configure();
if (!remotefs.is_empty()) {
file_access_network_client = memnew(FileAccessNetworkClient);
int port;
if (remotefs.contains(":")) {
port = remotefs.get_slicec(':', 1).to_int();
@@ -1394,14 +1390,12 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
} else {
port = 6010;
}
Error err = OS::get_singleton()->setup_remote_filesystem(remotefs, port, remotefs_pass, project_path);
Error err = file_access_network_client->connect(remotefs, port, remotefs_pass);
if (err) {
OS::get_singleton()->printerr("Could not connect to remotefs: %s:%i.\n", remotefs.utf8().get_data(), port);
goto error;
}
FileAccess::make_default<FileAccessNetwork>(FileAccess::ACCESS_RESOURCES);
}
if (globals->setup(project_path, main_pack, upwards, editor) == OK) {
@@ -1937,9 +1931,6 @@ error:
if (packed_data) {
memdelete(packed_data);
}
if (file_access_network_client) {
memdelete(file_access_network_client);
}
unregister_core_driver_types();
unregister_core_extensions();
@@ -3448,9 +3439,6 @@ void Main::cleanup(bool p_force) {
if (packed_data) {
memdelete(packed_data);
}
if (file_access_network_client) {
memdelete(file_access_network_client);
}
if (performance) {
memdelete(performance);
}