session: expose map to file send

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2017-09-21 22:14:11 -07:00
parent 0e8c5df478
commit c2dbdeb457
2 changed files with 6 additions and 4 deletions

View File

@ -9,10 +9,11 @@ import (
"google.golang.org/grpc" "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{ return fsutil.Send(stream.Context(), stream, dir, &fsutil.WalkOpt{
ExcludePatterns: excludes, ExcludePatterns: excludes,
IncludePatterns: includes, IncludePatterns: includes,
Map: _map,
}, progress) }, progress)
} }

View File

@ -29,6 +29,7 @@ type SyncedDir struct {
Name string Name string
Dir string Dir string
Excludes []string Excludes []string
Map func(*fsutil.Stat) bool
} }
// NewFSSyncProvider creates a new provider for sending files from client // 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 doneCh = sp.doneCh
sp.doneCh = nil 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 doneCh != nil {
if err != nil { if err != nil {
doneCh <- err doneCh <- err
@ -113,7 +114,7 @@ type progressCb func(int, bool)
type protocol struct { type protocol struct {
name string 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 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 err
} }
return sendDiffCopy(cc, srcPath, nil, nil, progress) return sendDiffCopy(cc, srcPath, nil, nil, progress, nil)
} }