diff --git a/docs/usage/faq.md b/docs/usage/faq.md index 64e9e8614..7ba196925 100644 --- a/docs/usage/faq.md +++ b/docs/usage/faq.md @@ -51,7 +51,8 @@ For security reasons JavaScript in the browser is not allowed to load local data You will run into Network Errors, due to the [Same Origin Policy](https://en.wikipedia.org/wiki/Same-origin_policy). There is a [File System API](https://wicg.github.io/file-system-access/) supported in Chrome -but not in Firefox or Safari. +but not in Firefox or Safari. See {ref}`nativefs-api` for experimental local file system +support. For development purposes, you can serve your files with a [web server](https://developer.mozilla.org/en-US/docs/Learn/Common_questions/set_up_a_local_testing_server). @@ -409,3 +410,12 @@ importlib.invalidate_caches() # Make sure Python notices the new .py file from mymodule import hello hello() ``` + +## Why changes made to IndexedDB don't persist? + +Unlike other filesystems, IndexedDB (pyodide.FS.filesystem.IDBFS) is an asynchronous filesystem. +This is because browsers offer only asynchronous interfaces for IndexedDB. +So in order to persist changes, you have to call +[`pyodide.FS.syncfs()`](https://emscripten.org/docs/api_reference/Filesystem-API.html#FS.syncfs). +See [Emscripten File System API](https://emscripten.org/docs/api_reference/Filesystem-API.html#persistent-data) +for more details. diff --git a/docs/usage/file-system.md b/docs/usage/file-system.md index 1137c44aa..2dc301d88 100644 --- a/docs/usage/file-system.md +++ b/docs/usage/file-system.md @@ -58,6 +58,8 @@ pyodide.runPython("import os; print(os.listdir('/mnt'))"); // ==> The list of files in the Node working directory ``` +(nativefs-api)= + # (Experimental) Using native file system in the browser You can access native file system from the browser using the