Merge pull request #3184 from mat007/fix-windows

Fix path separator on Windows
This commit is contained in:
Rolf Neugebauer 2018-09-10 22:26:43 +01:00 committed by GitHub
commit 0532b2889a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -454,7 +454,7 @@ func filesystem(m Moby, tw *tar.Writer, idMap map[string]uint32) error {
return errors.New("Did not specify path for file") return errors.New("Did not specify path for file")
} }
// tar archives should not have absolute paths // tar archives should not have absolute paths
if f.Path[0] == os.PathSeparator { if f.Path[0] == '/' {
f.Path = f.Path[1:] f.Path = f.Path[1:]
} }
mode := int64(0600) mode := int64(0600)

View File

@ -58,11 +58,11 @@ func tarPrefix(path string, tw tarWriter) error {
if path == "" { if path == "" {
return nil return nil
} }
if path[len(path)-1] != byte('/') { if path[len(path)-1] != '/' {
return fmt.Errorf("path does not end with /: %s", path) return fmt.Errorf("path does not end with /: %s", path)
} }
path = path[:len(path)-1] path = path[:len(path)-1]
if path[0] == byte('/') { if path[0] == '/' {
return fmt.Errorf("path should be relative: %s", path) return fmt.Errorf("path should be relative: %s", path)
} }
mkdir := "" mkdir := ""
@ -85,7 +85,7 @@ func tarPrefix(path string, tw tarWriter) error {
// ImageTar takes a Docker image and outputs it to a tar stream // ImageTar takes a Docker image and outputs it to a tar stream
func ImageTar(ref *reference.Spec, prefix string, tw tarWriter, trust bool, pull bool, resolv string) (e error) { func ImageTar(ref *reference.Spec, prefix string, tw tarWriter, trust bool, pull bool, resolv string) (e error) {
log.Debugf("image tar: %s %s", ref, prefix) log.Debugf("image tar: %s %s", ref, prefix)
if prefix != "" && prefix[len(prefix)-1] != byte('/') { if prefix != "" && prefix[len(prefix)-1] != '/' {
return fmt.Errorf("prefix does not end with /: %s", prefix) return fmt.Errorf("prefix does not end with /: %s", prefix)
} }