apache / apache/pouchdb

Explore using OPFS as an attachment store instead of idv/indexeddb blobs

Open
#9,173 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
17.6k
Forks
1.5k
PR merge metrics
No merged PRs in 30d

Description

Idea via @SourceR85 in https://github.com/apache/pouchdb/issues/9167#issuecomment-3755310344

[OPFS Link](https://developer.mozilla.org/en-US/docs/Web/API/File_System_API/Origin_private_file_system)

Things to consider:
- How can we ensure transactionality between two different data stores?
- IndexedDB transactions auto-commit on the end of the runloop, so we cannot do asynchronous tasks inside an IndexedDB transaction
- OPFS has a synchronous file access API, but that is only available in a worker for not-blocking-the-main-thread reasons
- A possible solution could write the attachments first and then start the IndexedDB transaction, but if the transaction fails, we might leave unreferenced attachments in OPFS that do not show up in IndexedDB. For that we would need a cleanup task that is not too expensive, so we can run it during compaction

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.