From c2dbdeb457ea665699a5d97f79eebfac4ab4726f Mon Sep 17 00:00:00 2001 From: Tonis Tiigi Date: Thu, 21 Sep 2017 22:14:11 -0700 Subject: [PATCH] session: expose map to file send Signed-off-by: Tonis Tiigi --- session/filesync/diffcopy.go | 3 ++- session/filesync/filesync.go | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/session/filesync/diffcopy.go b/session/filesync/diffcopy.go index 87dd0a32..c5a3b5bd 100644 --- a/session/filesync/diffcopy.go +++ b/session/filesync/diffcopy.go @@ -9,10 +9,11 @@ import ( "google.golang.org/grpc" ) -func sendDiffCopy(stream grpc.Stream, dir string, includes, excludes []string, progress progressCb) error { +func sendDiffCopy(stream grpc.Stream, dir string, includes, excludes []string, progress progressCb, _map func(*fsutil.Stat) bool) error { return fsutil.Send(stream.Context(), stream, dir, &fsutil.WalkOpt{ ExcludePatterns: excludes, IncludePatterns: includes, + Map: _map, }, progress) } diff --git a/session/filesync/filesync.go b/session/filesync/filesync.go index 53bd4248..5642f07a 100644 --- a/session/filesync/filesync.go +++ b/session/filesync/filesync.go @@ -29,6 +29,7 @@ type SyncedDir struct { Name string Dir string Excludes []string + Map func(*fsutil.Stat) bool } // NewFSSyncProvider creates a new provider for sending files from client @@ -94,7 +95,7 @@ func (sp *fsSyncProvider) handle(method string, stream grpc.ServerStream) error doneCh = sp.doneCh sp.doneCh = nil } - err := pr.sendFn(stream, dir.Dir, includes, excludes, progress) + err := pr.sendFn(stream, dir.Dir, includes, excludes, progress, dir.Map) if doneCh != nil { if err != nil { doneCh <- err @@ -113,7 +114,7 @@ type progressCb func(int, bool) type protocol struct { name string - sendFn func(stream grpc.Stream, srcDir string, includes, excludes []string, progress progressCb) error + sendFn func(stream grpc.Stream, srcDir string, includes, excludes []string, progress progressCb, _map func(*fsutil.Stat) bool) error recvFn func(stream grpc.Stream, destDir string, cu CacheUpdater, progress progressCb) error } @@ -236,5 +237,5 @@ func CopyToCaller(ctx context.Context, srcPath string, c session.Caller, progres return err } - return sendDiffCopy(cc, srcPath, nil, nil, progress) + return sendDiffCopy(cc, srcPath, nil, nil, progress, nil) }