You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-13 13:31:48 +00:00
[Web] Expose API to force file system sync.
Mostly useful for modules and extensions that can't use FileAccess to write files.
This commit is contained in:
@@ -46,6 +46,13 @@
|
|||||||
If [param use_global_execution_context] is [code]true[/code], the code will be evaluated in the global execution context. Otherwise, it is evaluated in the execution context of a function within the engine's runtime environment.
|
If [param use_global_execution_context] is [code]true[/code], the code will be evaluated in the global execution context. Otherwise, it is evaluated in the execution context of a function within the engine's runtime environment.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="force_fs_sync">
|
||||||
|
<return type="void" />
|
||||||
|
<description>
|
||||||
|
Force synchronization of the persistent file system (when enabled).
|
||||||
|
[b]Note:[/b] This is only useful for modules or extensions that can't use [FileAccess] to write files.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="get_interface">
|
<method name="get_interface">
|
||||||
<return type="JavaScriptObject" />
|
<return type="JavaScriptObject" />
|
||||||
<param index="0" name="interface" type="String" />
|
<param index="0" name="interface" type="String" />
|
||||||
|
|||||||
@@ -73,6 +73,7 @@ void JavaScriptBridge::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("download_buffer", "buffer", "name", "mime"), &JavaScriptBridge::download_buffer, DEFVAL("application/octet-stream"));
|
ClassDB::bind_method(D_METHOD("download_buffer", "buffer", "name", "mime"), &JavaScriptBridge::download_buffer, DEFVAL("application/octet-stream"));
|
||||||
ClassDB::bind_method(D_METHOD("pwa_needs_update"), &JavaScriptBridge::pwa_needs_update);
|
ClassDB::bind_method(D_METHOD("pwa_needs_update"), &JavaScriptBridge::pwa_needs_update);
|
||||||
ClassDB::bind_method(D_METHOD("pwa_update"), &JavaScriptBridge::pwa_update);
|
ClassDB::bind_method(D_METHOD("pwa_update"), &JavaScriptBridge::pwa_update);
|
||||||
|
ClassDB::bind_method(D_METHOD("force_fs_sync"), &JavaScriptBridge::force_fs_sync);
|
||||||
ADD_SIGNAL(MethodInfo("pwa_update_available"));
|
ADD_SIGNAL(MethodInfo("pwa_update_available"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -111,6 +112,8 @@ bool JavaScriptBridge::pwa_needs_update() const {
|
|||||||
Error JavaScriptBridge::pwa_update() {
|
Error JavaScriptBridge::pwa_update() {
|
||||||
return ERR_UNAVAILABLE;
|
return ERR_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
|
void JavaScriptBridge::force_fs_sync() {
|
||||||
|
}
|
||||||
void JavaScriptBridge::download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime) {
|
void JavaScriptBridge::download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public:
|
|||||||
void download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime = "application/octet-stream");
|
void download_buffer(Vector<uint8_t> p_arr, const String &p_name, const String &p_mime = "application/octet-stream");
|
||||||
bool pwa_needs_update() const;
|
bool pwa_needs_update() const;
|
||||||
Error pwa_update();
|
Error pwa_update();
|
||||||
|
void force_fs_sync();
|
||||||
|
|
||||||
static JavaScriptBridge *get_singleton();
|
static JavaScriptBridge *get_singleton();
|
||||||
JavaScriptBridge();
|
JavaScriptBridge();
|
||||||
|
|||||||
@@ -361,6 +361,11 @@ void JavaScriptBridge::download_buffer(Vector<uint8_t> p_arr, const String &p_na
|
|||||||
bool JavaScriptBridge::pwa_needs_update() const {
|
bool JavaScriptBridge::pwa_needs_update() const {
|
||||||
return OS_Web::get_singleton()->pwa_needs_update();
|
return OS_Web::get_singleton()->pwa_needs_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
Error JavaScriptBridge::pwa_update() {
|
Error JavaScriptBridge::pwa_update() {
|
||||||
return OS_Web::get_singleton()->pwa_update();
|
return OS_Web::get_singleton()->pwa_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void JavaScriptBridge::force_fs_sync() {
|
||||||
|
OS_Web::get_singleton()->force_fs_sync();
|
||||||
|
}
|
||||||
|
|||||||
@@ -196,6 +196,12 @@ void OS_Web::update_pwa_state_callback() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OS_Web::force_fs_sync() {
|
||||||
|
if (is_userfs_persistent()) {
|
||||||
|
idb_needs_sync = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Error OS_Web::pwa_update() {
|
Error OS_Web::pwa_update() {
|
||||||
return godot_js_pwa_update() ? FAILED : OK;
|
return godot_js_pwa_update() ? FAILED : OK;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,6 +69,7 @@ public:
|
|||||||
|
|
||||||
bool pwa_needs_update() const { return pwa_is_waiting; }
|
bool pwa_needs_update() const { return pwa_is_waiting; }
|
||||||
Error pwa_update();
|
Error pwa_update();
|
||||||
|
void force_fs_sync();
|
||||||
|
|
||||||
void initialize_joypads() override;
|
void initialize_joypads() override;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user