Skip to content

Commit

Permalink
Be less conservative when watching file system during a restart state
Browse files Browse the repository at this point in the history
Only go back to an error state if we have a buffer overflow
  • Loading branch information
rpaquay committed Jan 30, 2018
1 parent b8fa499 commit 08facf1
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions src/Core/Files/DirectoryChangeWatcher.RestartingState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace VsChromium.Core.Files {
public partial class DirectoryChangeWatcher {
private class RestartingState : State {
private static readonly bool _conservative = false;
/// <summary>
/// The date/time when we restarted watching files, but still observing disk activity before
/// resuming notifications.
Expand Down Expand Up @@ -49,31 +50,37 @@ public override State OnPolling() {
}

public override State OnWatcherErrorEvent(object sender, ErrorEventArgs args) {
// If there is another buffer overflow, go straight back to the error state,
// don't ever be conservative.
return BackToErrorState();
}

public override State OnWatcherFileChangedEvent(object sender, FileSystemEventArgs args, PathKind pathKind) {
return BackToErrorState();
return BackToState();
}

public override State OnWatcherFileCreatedEvent(object sender, FileSystemEventArgs args, PathKind pathKind) {
return BackToErrorState();
return BackToState();
}

public override State OnWatcherFileDeletedEvent(object sender, FileSystemEventArgs args, PathKind pathKind) {
return BackToErrorState();
return BackToState();
}

public override State OnWatcherFileRenamedEvent(object sender, RenamedEventArgs args, PathKind pathKind) {
return BackToErrorState();
return BackToState();
}

public override State OnWatcherAdded(FullPath directory, DirectoryWatcherhEntry watcher) {
return BackToErrorState();
return BackToState();
}

public override State OnWatcherRemoved(FullPath directory, DirectoryWatcherhEntry watcher) {
return BackToErrorState();
return BackToState();
}

private State BackToState() {
return _conservative ? BackToErrorState() : this;
}

private State BackToErrorState() {
Expand Down

0 comments on commit 08facf1

Please sign in to comment.