Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/fsPublic

Add the FileSystemObserver API#165

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
nathanmemmott wants to merge5 commits intowhatwg:main
base:main
Choose a base branch
Loading
fromnathanmemmott:file_system_observer

Conversation

@nathanmemmott
Copy link
Contributor

@nathanmemmottnathanmemmott commentedJul 18, 2024
edited by pr-previewbot
Loading

Add the FileSystemObserver API

Defines the FileSystemObserver API, an API to observe file system
change events.

See#123 andWICG/file-system-access#72

(SeeWHATWG Working Mode: Changes for more details.)


Preview |Diff

TechQuery, rektide, CetinSert, and viocha reacted with thumbs up emojiCetinSert reacted with laugh emojiCetinSert reacted with hooray emojiCetinSert reacted with heart emojiCetinSert and mitranim reacted with rocket emojiCetinSert and LostBeard reacted with eyes emoji
Nathan Memmottand others added4 commitsJuly 3, 2024 11:48
Gives each concept in the concepts section its own section.
Pulls out some implementation-defined concepts into a file systemconcept.This is so that the file system concept can be extended further in thefuture.
Pulls out some implementation-defined concepts into a file systemconcept.This is so that the file system concept can be extended further in thefuture.
@nathanmemmottnathanmemmott changed the titleFile system observerAdd the FileSystemObserver APIJul 19, 2024
Copy link
Collaborator

@mkruisselbrinkmkruisselbrink left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It would be nice if we could somehow specify more precisely what exact change events are triggered by changes to the bucket file system, since that should be entirely under control of user agents, so should be possible to be fully compatible between implementations. Not sure how to be go about doing that. Left a bunch of other comments as well...

a-sully reacted with thumbs up emoji
@nathanmemmottnathanmemmottforce-pushed thefile_system_observer branch 4 times, most recently from86ed1e4 to42a22b9CompareOctober 31, 2024 23:54
@nathanmemmott
Copy link
ContributorAuthor

The errors causing the build to fail were not introduced by this PR.

index.bs Outdated
1. Set |map|["root"] to |dir|.

1. Let |root| bean [=implementation-defined=] opaque [=string=].
1. Let |fileSystem| be[=/bucket file system=]'s [=file system/root=].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Somewhere in here fileSystem needs to be linked to a specific storage bottle for the correct storage bucket/origin. As written now it reads like there is one shared file system that all the storage buckets access. The old spec didn't really do this rigorously either, so it's probably okay to keep it a little bit hand-wavy (i.e. you might not need to go the whole way towards calling "obtain a local storage bottle map", and making it explicit that all the data for the file system is stored in the returned map), but we certainly don't want the spec to read like there is one "the bucket file system". Each storage bucket does need its own file system.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Let me know if the update makes sense.

index.bs Outdated
Exposed=(DedicatedWorker,SharedWorker,Window),
SecureContext,
RuntimeEnabled=FileSystemObserver
] interface FileSystemChangeRecord {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is there a reason this is a class and not just a dictionary? I think in retrospect DOM'sMutationRecord could have just been a dictionary as well. It's also not entirely clear to me why this has a constructor.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I asked the same question, and we had some offline discussion about this. The question of dictionary vs class seems to be the oldest open tag guidance request, but the most recent thinking in the issue thread there (w3ctag/design-principles#11 (comment)) seems to lean arguably in favor of using a class here, or at least not arguing against it (but that guidance certainly has changed a couple of times as the make-up of the tag has changed). I'm not sure what the latest thinking in this area is, and it would be nice if the TAG would actually write up something about this other than in that very long issue thread...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I'm not sure that accurately reflects the upthread discussion though with input from me and@domenic. In particular@domenic made the point there that for observer-related cases where it's just about data a dictionary would be more idiomatic. Having both a class and a constructor for it that takes a dictionary seems quite bloated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Perhttps://groups.google.com/a/chromium.org/g/blink-dev/c/6oOaFmia2dc/m/gx0KgpQqBQAJ, the latest plan seems to be to use a dictionary, especially since that is easier to upgrade to an interface later. I think that's a good plan, and updating the spec PR to match that would be good.

Copy link
ContributorAuthor

@nathanmemmottnathanmemmottDec 19, 2024
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Switched to dictionary.

);

[
Exposed=(DedicatedWorker,SharedWorker,Window),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why not(Worker, Window),FileSystemHandle is probably exposed in service worker contexts too?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

A separate API would be needed for service workers. The service worker becomes inactive after 30 seconds of no events. The change events received in theFileSystemObserver callback would not count as a service worker event. There are also privacy considerations around allowing a site to observe file changes without the user being aware.

"errored",
"modified",
"moved",
"unknown",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I am not sure whenerrored andunknown would happen.
I guesserrored could happen if unmounting a disk for instance.
I have no clue forunknown.
If we do not have a good usecase, should we remove from the initial PR?
Giving a description explaining what these values are might be nice.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Added definitions for each with examples.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What actions are expected for clients to take for "unknown" or "errored"?
For the use cases inhttps://github.com/whatwg/fs/blob/main/proposals/FileSystemObserver.md, I can see how they may want to react to "created", "deleted" and "content-modified", but not clear about the others.

Also ashttps://github.com/whatwg/fs/blob/main/proposals/FileSystemObserver.md#cross-platform-compatibility mentioned, we should consider about adding types that are generally supported, andunknown seems like platform specific?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For "unknown", they may want to poll their watched directory since they may have missed events. For "errored", they may want to try watching the folder again since they'll no longer be receiving.

unknown seems like platform specific?

An unknown can occur at least on Mac and Windows.

"appeared",
"disappeared",
"errored",
"modified",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What ismodified meaning?
If only touching the file, will it trigger a FileSystemChange?
If so, I would guess that this could trigger events where no information for the web page has changed (IIRC, access/modification dates are not exposed).
Or maybe it is restricted to changes in the content itself?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ideally this would only be content changes but we have limited information from the OS APIs so we cannot always filter out metadata changes. There will be some noisiness that a user agent can attempt to filter.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

then maybe it should named "content-modified".


<xmpclass=idl>
dictionary FileSystemObserverObserveOptions {
boolean recursive = false;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

If a folder being observed is removed, which callback will be called?
One for the folder, or one per each file in the folder, or depending on the OS?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

For each observer, there is only one callback. Each observer registration always has theirroot as the handle that was passed toobserve().

A folder may be moved to a recycling bin or deleted permanently. When moved to the recycling bin, this is interpreted as a move out of scope, so will be reported as one "disappeared" on the folder. When permanently deleted, the OS must delete its descendants recursively before deleting the folder. So a "disappeared" event for each descendant will be reported.

"disappeared",
"errored",
"modified",
"moved",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ismoved also coveringrename change?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why is moved event useful? Can we just fire a created change with new path and a deleted event with old path?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We'd lose information if we reported it that way. If we receive a appeared for a/b and a disappeared for a/c, we couldn't tell if that's rename/move or if a/c was just deleted and a/b created.

@nathanmemmott
Copy link
ContributorAuthor

The latest patch adds some logic that we decided on recently. We no longer send the changed handle for "disappeared", "errored", and "unknown".

@nathanmemmott
Copy link
ContributorAuthor

@annevk@mkruisselbrink@domenic@youennf PTAL again and let me know if this is ready to merge.

@asutherland I don't have permission to add you but please take a look. If someone does have permission, please add him.

Defines the FileSystemObserver API, an API to observe file systemchange events.Seewhatwg#123 andWICG/file-system-access#72
@mkruisselbrink
Copy link
Collaborator

This looks good to me, but it would be good to get at least one other person to sign off on this before merging.

@annevk
Copy link
Member

@nathanmemmott it seems you'll need to at least fill out OP.

@nathanmemmott
Copy link
ContributorAuthor

@annevk Ok updated the OP. Let me know if it looks correct.

@annevk
Copy link
Member

You haven't filed Gecko or WebKit bugs.

@nathanmemmott
Copy link
ContributorAuthor

Filed the bugs and updated the OP.

Exposed=(DedicatedWorker,SharedWorker,Window),
SecureContext
] interface FileSystemObserver {
constructor(FileSystemObserverCallback callback);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

To avoid duplication registration on the same handle, should the observer be global and have a connect() function instead (or just connect onobserve() if not yet)?

Comment on lines +2207 to +2208
"appeared",
"disappeared",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

"created" / "deleted" seems more common in file system APIs.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

"appeared" and "disappeared" were chosen since these events cover "created"/"moved in to scope" and "deleted"/"moved out of scope" respectively.

"appeared",
"disappeared",
"errored",
"modified",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

then maybe it should named "content-modified".

"disappeared",
"errored",
"modified",
"moved",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why is moved event useful? Can we just fire a created change with new path and a deleted event with old path?

"errored",
"modified",
"moved",
"unknown",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

What actions are expected for clients to take for "unknown" or "errored"?
For the use cases inhttps://github.com/whatwg/fs/blob/main/proposals/FileSystemObserver.md, I can see how they may want to react to "created", "deleted" and "content-modified", but not clear about the others.

Also ashttps://github.com/whatwg/fs/blob/main/proposals/FileSystemObserver.md#cross-platform-compatibility mentioned, we should consider about adding types that are generally supported, andunknown seems like platform specific?

@annevk
Copy link
Member

@asutherland I was pointed towardsmozilla/standards-positions#942 (comment). Did you mean to leave that comment here as well?

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@domenicdomenicdomenic left review comments

@annevkannevkannevk left review comments

@a-sullya-sullya-sully left review comments

@mkruisselbrinkmkruisselbrinkmkruisselbrink approved these changes

+3 more reviewers

@youennfyouennfyouennf left review comments

@szewaiszewaiszewai left review comments

@TomokiMiyauciTomokiMiyauciTomokiMiyauci left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

8 participants

@nathanmemmott@mkruisselbrink@annevk@domenic@youennf@szewai@TomokiMiyauci@a-sully

[8]ページ先頭

©2009-2025 Movatter.jp