Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a fairly isolated approach to update the tree in response to changes to hidden/system attributes for directories. (I'm not sure if it's the best approach, but sending it out for comment anyway.)
Scenarios this change addresses
Scenarios not addressed by this change
Next steps
As mentioned above, it's not feasible to monitor changes for the entire drive and refresh, which is implied by using
FindFirstChangeNotification
. Monitoring for external changes requires something more efficient so winfile can quickly discard irrelevant changes. One fairly incremental change is to useReadDirectoryChangesW
which indicates exactly what changed. I think this can be broken down into three parts:FindFirstChangeNotification
withReadDirectoryChangesW
. Normally this would be hard, but winfile'sChangeFileSystem
function is almost a direct translation of the output ofReadDirectoryChangesW
. Most of the changes here would be deleting code used to work around the limitations ofFindFirstChangeNotification
- theFSC_REFRESH
logic, the timer, etc.ReadDirectoryChangesExW
which offers another cute optimization by providing file attributes as part of the notification (so changes to non-directories can be immediately ignored with no processing.)ChangeFileSystem
and let this be driven through external notifications. Currently winfile is a bit split-brained in that it receives both internal and external notifications, and by applying a delay to external notifications, ensures the internal ones take precedence. But if internal and external are happening at the same time without a delay and performing explicit changes, it'd be relatively easy to create race conditions that leave the UI out of sync with the file system. Previously the internal changes were necessary to create a responsive UI when external changes can only indicate "something changed" and require a rescan, but withReadDirectoryChangesW
the UI could be fairly responsive without needing explicit internal change notifications.