-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify "origin private file system"-ness on a FileSystemHandle #110
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option here is to define "the root directory of the origin private file system" and check whether the handle "resolves" to that, but that doesn't set us up well for a multi-OPFS future (#92)
Eventually it would be nice to use Storage Buckets here, but I think this is the best we can do for now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just kidding, I just realized that I've been confusing the incubating Storage Buckets API with the already-specified storage bucket concept.
We could give a "file system root" the option to be/have a "storage bucket" (or bottle?), but there's currently no way to get a bucket from the current environment AFAICT? Sorry, I'm not as familiar with how this model is intended to work and I don't have all the context for the issues listed here https://wicg.github.io/storage-buckets/#storage-bucket-getdirectory @evanstade @ayuishii
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPFS is a storage endpoint and there's one storage bottle inside a storage bucket for each storage endpoint. (The endpoint is like a class, whereas the bottle is an instance of that class.) A storage shelf equates to a storage partition defined by a StorageKey. So a shelf contains buckets which contains bottles.
The issue mentioned in the storage buckets spec is that we need a version of this algorithm which works for any bucket. You'll notice if you drill down into "obtain a local storage bottle map" that it currently assumes the "default" bucket. This just means passing an additional parameter.
We do not currently have a way to go from bottle to bucket for any storage endpoint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the clarification @estade. I filed #112 to track making
getDirectory()
work for non-default buckets. Addressing whatwg/storage#2 seems like a prerequisite for adding another parameter to "obtain a local storage bottle map"?We just need some way to tie a FileSystemHandle to its root (i.e. two files of the same "file system path" must be considered different if they're from different buckets). There's one OPFS instance per storage bucket, though since there's also only one "fileSystem" bottle per bucket, then using the bottle would also work... though currently, it seems like it's only possible to get a "storage bottle map" and not the storage bottle itself. It seems a bit clumsy to associate a "storage bottle map" with each "file system locator"
Which raises the question of... why don't we just point to the directory entry at
map["root"]
directly? That would essentially make every "file system locator" a relative path, which on one hand could improve the hand-waviness of the recently-added "locate an entry" and "get the locator" methods, but on the other hand re-raises some of the questions of #59 (i.e. what happens if a root is deleted or moved? #9 (comment))So, for now at least, I'd prefer to keep "file system locators" absolute and find a way to point to a bottle/bucket :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there's any reason not to have a way to retrieve a bottle. We do have ways to get a bucket, but they're currently specified here instead of in the storage spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if we define OPFS in terms of https://storage.spec.whatwg.org/#obtain-a-local-storage-bottle-map you could make this rely less on magic. But that's a more substantial overhaul.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ack. I'll leave this PR as just specifying OPFS-ness on a
FileSystemHandle
, then we can leave better defining the OPFS itself (in terms of the Storage spec) to a follow-up