watcher_windows.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. //go:build windows
  2. // +build windows
  3. /*
  4. Copyright 2020 Docker Compose CLI authors
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. */
  15. package watch
  16. import (
  17. "github.com/tilt-dev/fsnotify"
  18. )
  19. // TODO(nick): I think the ideal API would be to automatically increase the
  20. // size of the buffer when we exceed capacity. But this gets messy,
  21. // because each time we get a short read error, we need to invalidate
  22. // everything we know about the currently changed files. So for now,
  23. // we just provide a way for people to increase the buffer ourselves.
  24. //
  25. // It might also pay to be clever about sizing the buffer
  26. // relative the number of files in the directory we're watching.
  27. func MaybeIncreaseBufferSize(w *fsnotify.Watcher) {
  28. w.SetBufferSize(DesiredWindowsBufferSize())
  29. }