From 257c9b2a70300faf1fa03f66f1b53176a0fe5c11 Mon Sep 17 00:00:00 2001 From: Rico Wind Date: Fri, 16 Jun 2017 10:51:33 +0200 Subject: [PATCH] Use extended path syntax on windows when extracting tarball in download script R=hinoka@chromium.org Bug: Change-Id: I027ac560beeea2ebf38fe6ddcb4e707efd3f615a Reviewed-on: https://chromium-review.googlesource.com/538612 Reviewed-by: Ryan Tseng Reviewed-by: Robbie Iannucci Commit-Queue: Rico Wind --- download_from_google_storage.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/download_from_google_storage.py b/download_from_google_storage.py index f75f50cbb..c9f5f676c 100755 --- a/download_from_google_storage.py +++ b/download_from_google_storage.py @@ -284,6 +284,11 @@ def _downloader_worker_thread(thread_num, q, force, base_url, continue with tarfile.open(output_filename, 'r:gz') as tar: dirname = os.path.dirname(os.path.abspath(output_filename)) + # If there are long paths inside the tarball we can get extraction + # errors on windows due to the 260 path length limit (this includes + # pwd). Use the extended path syntax. + if sys.platform == 'win32': + dirname = '\\\\?\\%s' % dirname if not _validate_tar_file(tar, os.path.basename(extract_dir)): out_q.put('%d> Error: %s contains files outside %s.' % ( thread_num, output_filename, extract_dir))