Skip to content

Commit 1e11cf5

Browse files
authored
Merge pull request #24 from Rohansi/add-canwatchimpls
Add CanWatch impls to physical and composite FS
2 parents 8b6efb5 + 67583e5 commit 1e11cf5

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

src/Zio/FileSystems/AggregateFileSystem.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@ protected override UPath ConvertPathFromDelegate(UPath path)
406406
// Watch API
407407
// ----------------------------------------------
408408

409+
/// <inheritdoc />
410+
protected override bool CanWatchImpl(UPath path)
411+
{
412+
// Always allow watching because a future filesystem can be added that matches this path.
413+
return true;
414+
}
415+
409416
/// <inheritdoc />
410417
protected override IFileSystemWatcher WatchImpl(UPath path)
411418
{

src/Zio/FileSystems/ComposeFileSystem.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,12 @@ protected override IEnumerable<UPath> EnumeratePathsImpl(UPath path, string sear
197197
// ----------------------------------------------
198198
// Watch API
199199
// ----------------------------------------------
200+
201+
/// <inheritdoc />
202+
protected override bool CanWatchImpl(UPath path)
203+
{
204+
return NextFileSystemSafe.CanWatch(ConvertPathToDelegate(path));
205+
}
200206

201207
/// <inheritdoc />
202208
protected override IFileSystemWatcher WatchImpl(UPath path)

src/Zio/FileSystems/MountFileSystem.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,13 @@ IEnumerable<UPath> EnumeratePathFromFileSystem(UPath subPath, bool failOnInvalid
627627
}
628628
}
629629

630+
/// <inheritdoc />
631+
protected override bool CanWatchImpl(UPath path)
632+
{
633+
// Always allow watching because a future filesystem can be added that matches this path.
634+
return true;
635+
}
636+
630637
/// <inheritdoc />
631638
protected override IFileSystemWatcher WatchImpl(UPath path)
632639
{

src/Zio/FileSystems/PhysicalFileSystem.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,17 @@ protected override IEnumerable<UPath> EnumeratePathsImpl(UPath path, string sear
510510
// ----------------------------------------------
511511
// Watch API
512512
// ----------------------------------------------
513+
514+
/// <inheritdoc />
515+
protected override bool CanWatchImpl(UPath path)
516+
{
517+
if (IsWithinSpecialDirectory(path))
518+
{
519+
return SpecialDirectoryExists(path);
520+
}
521+
522+
return Directory.Exists(ConvertPathToInternal(path));
523+
}
513524

514525
/// <inheritdoc />
515526
protected override IFileSystemWatcher WatchImpl(UPath path)

0 commit comments

Comments
 (0)