dotnet/runtime

Split polling functionality from PhysicalFilesWatcher into a separate type

Open

#48.602 geöffnet am 22. Feb. 2021

Auf GitHub ansehen
 (2 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)C# (5.445 Forks)batch import
area-Extensions-FileSystemhelp wanted

Repository-Metriken

Stars
 (17.886 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 12T 11h) (661 gemergte PRs in 30 T)

Beschreibung

Description

Related to https://github.com/dotnet/runtime/issues/17111

We have a polling implementation as a mode of https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.fileproviders.physical.physicalfileswatcher?view=dotnet-plat-ext-5.0 when pollForChanges is set true.

For this to actually be useful (and raise events like a normal file watcher) you also need to set UseActivePolling: https://github.com/dotnet/runtime/blob/8a52f1e948b6f22f418817ec1068f07b8dae2aa5/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFilesWatcher.cs#L109

Which can only be set by the UseActivePolling in the PhysicalFileProvider: https://github.com/dotnet/runtime/blob/8a52f1e948b6f22f418817ec1068f07b8dae2aa5/src/libraries/Microsoft.Extensions.FileProviders.Physical/src/PhysicalFileProvider.cs#L163-L169

In addition the PhysicalFilesWatcher requires things like a FileSystemWatcher which is irrelevant when polling, fails to watch full paths which is also an unnecessary limitation if you don't have a "watch" tied to a root path, and is coupled to Physical implementation, which it need not be, and could interact through the FileSystem abstractions themselves (either IFileProvider, or IFileInfo/IDirectoryContents)

In addition to this, the current PollingFileChangeToken are PollingWildCardChangeToken are somewhat crippled as they can only poll and cannnot be easily made to raise events (we kept everything internal).

Related: https://github.com/dotnet/runtime/issues/36091

Contributor Guide