Skip to content

FileSystemWatcher.Linux/OSX: raise Error event when FileSystemWatcher's watched directory is deleted or moved.#128360

Open
tmds wants to merge 2 commits into
dotnet:mainfrom
tmds:fsw-detect-root-delete
Open

FileSystemWatcher.Linux/OSX: raise Error event when FileSystemWatcher's watched directory is deleted or moved.#128360
tmds wants to merge 2 commits into
dotnet:mainfrom
tmds:fsw-detect-root-delete

Conversation

@tmds
Copy link
Copy Markdown
Member

@tmds tmds commented May 19, 2026

Fixes #126295.

@tmds tmds requested review from adamsitnik and svick May 19, 2026 09:08
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label May 19, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-io
See info in area-owners.md if you want to be subscribed.

=> new InternalBufferOverflowException(SR.Format(SR.FSW_BufferOverflow, directoryPath));

private static DirectoryNotFoundException CreateWatchedDirectoryDeletedOrMovedException(string directoryPath)
=> new DirectoryNotFoundException(SR.Format(SR.FSW_WatchedDirectoryDeletedOrMoved, directoryPath));
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now used on Linux/OSX. On Windows, the exception is: System.ComponentModel.Win32Exception (5): Access is denied.

@tmds tmds force-pushed the fsw-detect-root-delete branch from 8612e74 to c52b3a7 Compare May 20, 2026 09:00
@tmds tmds changed the title FileSystemWatcher.Linux: raise Error event when FileSystemWatcher's watched directory is deleted or moved. FileSystemWatcher.Linux/OSX: raise Error event when FileSystemWatcher's watched directory is deleted or moved. May 20, 2026
@tmds
Copy link
Copy Markdown
Member Author

tmds commented May 20, 2026

@adamsitnik @svick this is up for review.

@tmds tmds force-pushed the fsw-detect-root-delete branch from c52b3a7 to 3ffa752 Compare May 21, 2026 04:49
@svick
Copy link
Copy Markdown
Member

svick commented May 21, 2026

There is a PhysicalFilesWatcher test that references this issue. I think it should be updated. My proposed change is at 44b37b9, feel free to cherry-pick that commit.

Otherwise, the changes in PhysicalFilesWatcher and the exception type LGTM.

@tmds
Copy link
Copy Markdown
Member Author

tmds commented Jun 2, 2026

@adamsitnik @dotnet/area-system-io ptal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.IO community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FileSystemWatcher does not detect watched directory deletion on Linux

2 participants