session: better backwards compatibility with old servers

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
docker-18.09
Tonis Tiigi 2017-11-01 11:42:42 -07:00
parent b3a6843275
commit 59d3b4c15b
1 changed files with 5 additions and 4 deletions

View File

@ -68,14 +68,15 @@ func (sp *fsSyncProvider) handle(method string, stream grpc.ServerStream) error
opts, _ := metadata.FromContext(stream.Context()) // if no metadata continue with empty object opts, _ := metadata.FromContext(stream.Context()) // if no metadata continue with empty object
dirName := ""
name, ok := opts[keyDirName] name, ok := opts[keyDirName]
if !ok || len(name) != 1 { if ok && len(name) > 0 {
return errors.New("no dir name in request") dirName = name[0]
} }
dir, ok := sp.dirs[name[0]] dir, ok := sp.dirs[dirName]
if !ok { if !ok {
return errors.Errorf("no access allowed to dir %q", name[0]) return errors.Errorf("no access allowed to dir %q", dirName)
} }
var excludes []string var excludes []string