xoofx / zio

A cross-platform abstract/virtual filesystem framework with many built-ins filesystems for .NET
BSD 2-Clause "Simplified" License
817 stars 61 forks source link

Fix IFileSystemWatcher instances not being removed from AggregateFSWs #32

Closed Rohansi closed 6 years ago

Rohansi commented 6 years ago

The watchers had FileSystem set to the MountFileSystem and removal was checking for the internal IFileSystem being watched. Those are never going to be the same so the instances were never removed.

I noticed this when I had a PhysicalFileSystem mounted, watched the MountFileSystem, then remove (and dispose) the physical FS instance. When the watcher picks something up it'll throw an ObjectDisposedException trying to use the PhysicalFileSystem instance.

I also moved the removal (and disposal) of those FSWs to happen before FS disposal could happen to avoid a similar disposal issue.

xoofx commented 6 years ago

Thanks! (Glad that you are using it! as I don't have the time for my own project, so it's difficult to evaluate how much the library is reliable on this)