diffcopy.go 722 B

12345678910111213141516171819202122232425262728293031
  1. package filesync
  2. import (
  3. "time"
  4. "google.golang.org/grpc"
  5. "github.com/Sirupsen/logrus"
  6. "github.com/tonistiigi/fsutil"
  7. )
  8. func sendDiffCopy(stream grpc.Stream, dir string, includes, excludes []string, progress progressCb) error {
  9. return fsutil.Send(stream.Context(), stream, dir, &fsutil.WalkOpt{
  10. ExcludePatterns: excludes,
  11. IncludePaths: includes, // TODO: rename IncludePatterns
  12. }, progress)
  13. }
  14. func recvDiffCopy(ds grpc.Stream, dest string, cu CacheUpdater) error {
  15. st := time.Now()
  16. defer func() {
  17. logrus.Debugf("diffcopy took: %v", time.Since(st))
  18. }()
  19. var cf fsutil.ChangeFunc
  20. if cu != nil {
  21. cu.MarkSupported(true)
  22. cf = cu.HandleChange
  23. }
  24. return fsutil.Receive(ds.Context(), ds, dest, cf)
  25. }