-
-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Html5 saving #112
Comments
Hey @fireworx! The database should be automatically saved when you close it and should be stored in the |
try it with and without dummysave(), it will not write /userfs/test.db when changes are made even, if i close the page, no save |
Hi @fireworx I currently don't have time to actually run that code. # Throw away any table that was already present
db.drop_table(table_name) I'll try to run your code as soon as I can. |
its your own democode ;-) meantime i checked if it is a browserbased problem, but it isn't. (chrome/firefox) |
Hi @fireworx, I finally had some time to try and replicate the issue. I'll try to find some time as soon as possible to figure out what is going on and hopefully get it fixed. |
It seems that Godot doesn't automatically sync the userfs in HTML. Easiest work-around at the time of writing seems to be to simply open a dummy file as such: var file := File.new()
file.open("user://whatever", File.WRITE)
file.close() This will force Godot to sync the filesystem when this file closes. |
This seems to be best approach to tackle this issue: if OS.get_name() in ["HTML5"]:
var engine = JavaScript.get_interface("engine")
var GodotFS = engine.rtenv.GodotFS
if not GodotFS._syncing:
GodotFS.sync() I'll see if I can implement this in the C++ |
I've ported the above code snippet and added it to the As a result, there's two options here:
|
Hi @fireworx I've decided on an entirely different approach, namely to always use the custom VFS for HTML targets. A small concern is the matter of speed (SQLite's default VFS vs. my custom VFS), but I think the difference will be negligible. |
Posting this here for future reference: #ifdef __EMSCRIPTEN__
/* In the case of the web build, we'll have to manually force an update of the file system (IndexedDB) */
/* The method used here is dangerous as the GodotFS object *might* not be exposed on official builds due to the closure compiler renaming/minimizing the property */
Ref<JavaScriptObject> engine = JavaScript::get_singleton()->get_interface("engine");
Ref<JavaScriptObject> rtenv = engine->get("rtenv");
Ref<JavaScriptObject> GodotFS = rtenv->get("GodotFS");
if (!GodotFS->get("_syncing"))
{
GODOT_LOG(0, "Manually forcing GodotFS to sync!");
GodotFS->call("sync");
}
#endif |
This issue has now been fixed in the latest release (https://github.com/2shady4u/godot-sqlite/releases/tag/v3.5) 🥳 Thank you for reporting this issue and enjoy your coding! |
closing of db doesn't save in indexdb,
but saving after closing db, a new dummy file will enforce that db is saved
maybe a chance for a generally workaround ;-)
The text was updated successfully, but these errors were encountered: