about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2014-10-14 21:43:48 +0700
committerSergey M <dstftw@gmail.com>2014-10-14 21:43:48 +0700
commit5f58165def551921741b44772c9bf31a237a4ac8 (patch)
treef09ae4ce342ba6ffd3bf5e636ffc0fdc03f8b5df
parentbd4e40df1aaef96dcde64dd64793b5152ae66055 (diff)
downloadyoutube-dl-5f58165def551921741b44772c9bf31a237a4ac8.tar.gz
youtube-dl-5f58165def551921741b44772c9bf31a237a4ac8.tar.xz
youtube-dl-5f58165def551921741b44772c9bf31a237a4ac8.zip
[extractor/common] Fix dumping requests with long file abspath on Windows
-rw-r--r--youtube_dl/extractor/common.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/youtube_dl/extractor/common.py b/youtube_dl/extractor/common.py
index 450c7dfd6..e8366f7f9 100644
--- a/youtube_dl/extractor/common.py
+++ b/youtube_dl/extractor/common.py
@@ -281,6 +281,12 @@ class InfoExtractor(object):
             raw_filename = basen + '.dump'
             filename = sanitize_filename(raw_filename, restricted=True)
             self.to_screen('Saving request to ' + filename)
+            # Working around MAX_PATH limitation on Windows (see
+            # http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx)
+            if os.name == 'nt':
+                absfilepath = os.path.abspath(filename)
+                if len(absfilepath) > 259:
+                    filename = '\\\\?\\' + absfilepath
             with open(filename, 'wb') as outf:
                 outf.write(webpage_bytes)