summaryrefslogtreecommitdiff
path: root/docker
diff options
context:
space:
mode:
authorJoffrey F <joffrey@docker.com>2018-11-26 17:33:30 -0800
committerJoffrey F <joffrey@docker.com>2018-11-26 17:34:26 -0800
commit114630161a08b19489e464ad2c1a70ccccc9cc74 (patch)
tree4cdca2a00f91f6b1d5b709636e902ccaf0170d57 /docker
parentf3231a1ebb6512b0ee95a380b9105618b59c8758 (diff)
downloaddocker-py-c6356-longpath-prefix.tar.gz
Correctly handle longpath prefix in process_dockerfile when joining pathsc6356-longpath-prefix
Signed-off-by: Joffrey F <joffrey@docker.com>
Diffstat (limited to 'docker')
-rw-r--r--docker/api/build.py9
-rw-r--r--docker/constants.py1
2 files changed, 9 insertions, 1 deletions
diff --git a/docker/api/build.py b/docker/api/build.py
index 0486dce..3a67ff8 100644
--- a/docker/api/build.py
+++ b/docker/api/build.py
@@ -339,7 +339,14 @@ def process_dockerfile(dockerfile, path):
abs_dockerfile = dockerfile
if not os.path.isabs(dockerfile):
abs_dockerfile = os.path.join(path, dockerfile)
-
+ if constants.IS_WINDOWS_PLATFORM and path.startswith(
+ constants.WINDOWS_LONGPATH_PREFIX):
+ abs_dockerfile = '{}{}'.format(
+ constants.WINDOWS_LONGPATH_PREFIX,
+ os.path.normpath(
+ abs_dockerfile[len(constants.WINDOWS_LONGPATH_PREFIX):]
+ )
+ )
if (os.path.splitdrive(path)[0] != os.path.splitdrive(abs_dockerfile)[0] or
os.path.relpath(abs_dockerfile, path).startswith('..')):
# Dockerfile not in context - read data to insert into tar later
diff --git a/docker/constants.py b/docker/constants.py
index 7565a76..1ab11ec 100644
--- a/docker/constants.py
+++ b/docker/constants.py
@@ -14,6 +14,7 @@ INSECURE_REGISTRY_DEPRECATION_WARNING = \
'is deprecated and non-functional. Please remove it.'
IS_WINDOWS_PLATFORM = (sys.platform == 'win32')
+WINDOWS_LONGPATH_PREFIX = '\\\\?\\'
DEFAULT_USER_AGENT = "docker-sdk-python/{0}".format(version)
DEFAULT_NUM_POOLS = 25