|
|
|
@ -121,11 +121,14 @@ def download_document(url, document_path):
|
|
|
|
|
|
|
|
|
|
# Check if destination path is too long (Windows filename limitation)
|
|
|
|
|
try:
|
|
|
|
|
# Create output directories as required
|
|
|
|
|
os.makedirs(os.path.dirname(document_path), exist_ok=True)
|
|
|
|
|
|
|
|
|
|
# Check if empty file can be created in this location
|
|
|
|
|
open(document_path, 'a').close()
|
|
|
|
|
except FileNotFoundError:
|
|
|
|
|
# Tweak long path for Windows
|
|
|
|
|
document_path = '\\\\?\\' + os.path.abspath(document_path)
|
|
|
|
|
|
|
|
|
|
# Create output directories as required
|
|
|
|
|
os.makedirs(os.path.dirname(document_path), exist_ok=True)
|
|
|
|
|
|
|
|
|
|
# Check if a non-empty file exists
|
|
|
|
|