admin管理员组

文章数量:1320888

Simple but deceptively difficult question:

I got what I was trying to get working here: Using OPFS (Origin Private FileSystem) with SQLite WASM in background.js Chrome Extention (Worker is not defined error)

But, I can't seem to find where the .sqlite3 file is stored?

I have tried sudo find / -type f -name "mydb.sqlite3" and sudo find / -type f -name "*.sqlite3" searching the entire puter for the file but it doesn't seem to be found. This tells me I must be missing something fundamental about this?

I know the database is remembering data somehow because I can view the console messages after refreshing the extention and see more and more rows when I read the database.

I have tried the OPFS extention to try viewing the database but that doesn't work either (refer to screenshot)

I feel like a plete idiot that I can't figure out where this file is being stored. Anyone know? I just want to be able to view it with an SQLite reader and verify everything is storing correctly in an easier manner. Currently I can query it using SQL mands to verify it works but this is very slow and tedious and I feel unnecessary. In my screenshot it says LIMIT 3, but I can remove that to show all rows just fine just FYI

Simple but deceptively difficult question:

I got what I was trying to get working here: Using OPFS (Origin Private FileSystem) with SQLite WASM in background.js Chrome Extention (Worker is not defined error)

But, I can't seem to find where the .sqlite3 file is stored?

I have tried sudo find / -type f -name "mydb.sqlite3" and sudo find / -type f -name "*.sqlite3" searching the entire puter for the file but it doesn't seem to be found. This tells me I must be missing something fundamental about this?

I know the database is remembering data somehow because I can view the console messages after refreshing the extention and see more and more rows when I read the database.

I have tried the OPFS extention to try viewing the database but that doesn't work either (refer to screenshot)

I feel like a plete idiot that I can't figure out where this file is being stored. Anyone know? I just want to be able to view it with an SQLite reader and verify everything is storing correctly in an easier manner. Currently I can query it using SQL mands to verify it works but this is very slow and tedious and I feel unnecessary. In my screenshot it says LIMIT 3, but I can remove that to show all rows just fine just FYI

Share Improve this question edited Nov 6, 2023 at 1:58 Joseph Astrahan asked Nov 6, 2023 at 1:21 Joseph AstrahanJoseph Astrahan 9,09214 gold badges94 silver badges162 bronze badges 4
  • 3 OPFS files are private to the origin of the page and not visible to the user like the regular file system. It is a browser specific implementation and there is no one way to find it. Source: web.dev/articles/… – clamentjohn Commented Nov 6, 2023 at 2:21
  • If this is the case, how do I save the data from the persistant storage to a file? How can I export all the data to an .sqlite3 file? and is it possible to do this automatically? (like as soon as I read the database I can just export it constantly?) – Joseph Astrahan Commented Nov 6, 2023 at 2:34
  • Use the non-private FS: showSaveFilePicker. – woxxom Commented Nov 6, 2023 at 9:28
  • (The sqlite JS/WASM developer here...) Regarding exporting them, see the docs: sqlite/wasm/doc/trunk/cookbook.md#uldl – sgbeal Commented Nov 30, 2023 at 12:14
Add a ment  | 

2 Answers 2

Reset to default 8

Note that what I'm going to tell you is an implementation detail of Chrome that could change at any time, but at the time of this writing, this approach works on macOS, the platform you're using according to the screenshots. In the console (not the DevTools console, the actual system console), enter the following mand, customizing the "some unique string you know is in the OPFS file" part:

find ~/Library/Application\ Support/Google/Chrome/Default/File\ System -type f -exec grep -q "some unique string you know is in the OPFS file" {} \; -print

On macOS, all OPFS files are stored in ~/Library/Application Support/Google/Chrome/Default/File System, but the problem is locating the file you're interested in, since the file names don't correspond to the file names the developer used in their OPFS code and the folder names don't correspond to the origins. A little grep magic and knowledge about the file contents to the rescue…

At least going by the spec, OPFS files cannot be located on file system of the operating system. The actual storage of files and their location is implementation details of browser.

from the MDN docs:

Browsers persist the contents of the OPFS to disk somewhere, but you cannot expect to find the created files matched one-to-one. The OPFS is not intended to be visible to the user.

If you want to export file, you need to write code for reading the file from OPFS & download on to user's file system (on some event, like click of a button). However, OPFS file can't be automatically sync'ed with a file on the OS file system

本文标签: javascriptWhere does OPFS with SQLite WASM store files for the chrome extensionStack Overflow