|
|
|
@ -121,12 +121,15 @@ 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)
|
|
|
|
|
os.makedirs(os.path.dirname(document_path), exist_ok=True)
|
|
|
|
|
|
|
|
|
|
# Check if a non-empty file exists
|
|
|
|
|
if os.path.isfile(document_path) and os.path.getsize(document_path) > 0:
|
|
|
|
|