Skip to content

Notify, etc. cannot Subscribe to multiple target Types #1067

Description

@pinkfloydx33

Using FileSytemTypes.DirectoryOrFile or the equivalent FileSytemTypes.Directory | FileSytemTypes.File does not work when using change notifications, for example Notify.OnCreated(). No events will be returned, even if they occur. You need to create two event watches.

I think this is because ChangeDescriptionExtensions.Matches has the test backwards:

if (changeDescription.ChangeType != changeType ||
!changeDescription.FileSystemType.HasFlag(fileSystemType))
{
return false;
}

I believe it should should be:

if (changeDescription.ChangeType != changeType ||
    !fileSystemType.HasFlag(changeDescription.FileSystemType)
{
    return false;
}

And actually -- changeType is a flags enum as well; This indicates that there would also be a bug if you specified multiple watcher change types... so it probably should be:

if (!changeType.HasFlag(changeDescription.ChangeType) ||
    !fileSystemType.HasFlag(changeDescription.FileSystemType)
{
    return false;
}

I don't know if this is the only place that needs fixing.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions