limit path length for --write-pages output on Windows (#2733)

This commit is contained in:
Mike Fährmann 2022-07-06 18:56:23 +02:00
parent 04bed1eba3
commit 92b75bcdce
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -8,6 +8,7 @@
"""Common classes and constants used by extractor modules."""
import os
import re
import ssl
import time
@ -477,11 +478,16 @@ class Extractor():
fname = "{:>02}_{}".format(
Extractor._dump_index,
Extractor._dump_sanitize('_', response.url)
)[:250]
Extractor._dump_sanitize('_', response.url),
)
if util.WINDOWS:
path = os.path.abspath(fname)[:255]
else:
path = fname[:251]
try:
with open(fname + ".dump", 'wb') as fp:
with open(path + ".txt", 'wb') as fp:
util.dump_response(
response, fp, headers=(self._write_pages == "all"))
except Exception as e: