pkg/archive: keep walkRoot clean if source is /

Previously, getWalkRoot("/", "foo") would return "//foo"
Now it returns "/foo"

Signed-off-by: Tibor Vass <tibor@docker.com>
(cherry picked from commit 7410f1a859063d4ed3d8fca44f27bdde4c2cb5a3)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Upstream-commit: 8677bbe3f31a8e4516e1ba413ce1063c803ea10c
Component: engine
This commit is contained in:
Tibor Vass
2019-06-12 23:01:04 +00:00
committed by Sebastiaan van Stijn
parent 36f18a1f78
commit 6532144af4

View File

@ -7,6 +7,7 @@ import (
"errors"
"os"
"path/filepath"
"strings"
"syscall"
"github.com/docker/docker/pkg/idtools"
@ -26,7 +27,7 @@ func fixVolumePathPrefix(srcPath string) string {
// can't use filepath.Join(srcPath,include) because this will clean away
// a trailing "." or "/" which may be important.
func getWalkRoot(srcPath string, include string) string {
return srcPath + string(filepath.Separator) + include
return strings.TrimSuffix(srcPath, string(filepath.Separator)) + string(filepath.Separator) + include
}
// CanonicalTarNameForPath returns platform-specific filepath