Skip to content

Clarification of reads while AccessHandle has lock #325

@jlongster

Description

@jlongster

In https://github.com/WICG/file-system-access/blob/main/AccessHandle.md#locking-semantics it says:

Creating a File through getFile() would be possible when a lock is in place. The returned File behaves as it currently does in OPFS i.e., it is invalidated if file contents are changed after it was created. It is worth noting that these Files could be used to observe changes done through the new API, even if a lock is still being held.

With something like SQLite (https://jlongster.com/future-sql-web), the read behavior while someone has a lock needs to be very explicitly defined.

The behavior I need to implement is blocking any reads while I have an exclusive write lock. A File might be created after a write is made, but before the file the file is unlocked. I don't think there's any way for me to make sure that a process doesn't read it until the file is unlocked?

I need to be able to write a bunch of data down before anybody else can read it. If they can read it, they might read partial writes which would be up being corrupted data.

Can we implement something more like posix advisory locks? It would be even better if we could have something like locking specific bytes in a file so we can have different types of locks (see fcntl https://man7.org/linux/man-pages/man2/fcntl.2.html). Even just a single byte would be fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    access handlesIssues related to the new Access Handles proposal

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions