WICG / file-system-access

Expose the file system on the user’s device, so Web apps can interoperate with the user’s native applications.
https://wicg.github.io/file-system-access/
Other
669 stars 66 forks source link

File Handle Permission revoked even though tabs were not given #337

Closed HollaG closed 3 years ago

HollaG commented 3 years ago

In my web app, one of my components is a file browser for images stored in a directory chosen by the user. After the user grants access to a directory from window.showDirectoryPicker(), I recursively get each image file's FileHandle and store it in IndexedDB.

The user can then select an image link to preview an image loaded via fileHandle.getFile() which is retrieved from IndexedDB.

However, I have noticed that when multiple calls to fileHandle.getFile() are made, sometimes it will fail with DOMException: The request is not allowed by the user agent or the platform in the current context.

This usually occurs after multiple calls to fileHandle.getFile(). Is this intended behaviour?

I have not found this issue to be reliably reproducible.

mkruisselbrink commented 3 years ago

This sounds more like an implementation than a spec issue, and as such is more suited for crbug.com. Having said that, while it does not sounds like this is intended behavior, it certainly is possible in the current chrome implementation for permissions to be revoked if no FileHandle or DirectoryHandle objects are alive (i.e. if the only references to them are in IndexedDB). It's not entirely clear to me from your description if that is what might be happening here. It is always best practice when fetching a handle from IndexedDB to explicitly check and/or request the permissions you would like to have for the returned handles.