dotnet/runtime

Split polling functionality from PhysicalFilesWatcher into a separate type

オープン

#48,602 opened on 2021/02/22

 (2 件のコメント) (2 件のリアクション) (0 人の担当者)C# (5,445 件のフォーク)batch import
area-Extensions-FileSystemhelp wanted

Repository metrics

Stars
 (17,886 個のスター)
PR merge metrics
 (平均マージ 12d 11h) (30d で 661 merged PRs)

説明

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

コントリビューターガイド