Skip to content

Commit

Permalink
Added check for creating directories whose path names are too long
Browse files Browse the repository at this point in the history
  • Loading branch information
bartvbl committed Jun 28, 2017
1 parent 8d12e72 commit 7f60ef8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion scrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,13 @@ def sanitiseFilename(filename):
def makeDirectories(path):
cleaned_path = sanitisePath(path)
if not os.path.exists(cleaned_path):
os.makedirs(os.path.abspath(cleaned_path))
if len(cleaned_path) >= 254 and 'Windows' in platform.system():
print('COULD NOT CREATE A FOLDER AT: ')
print(cleaned_path)
print('Windows is unable to handle paths longer than 255 characters.')
print('Any files dumped in these directories will be redirected to the overflow directory.')
else:
os.makedirs(os.path.abspath(cleaned_path))
return cleaned_path

# Windows has this amazing feature called "255 character file path limit"
Expand Down

0 comments on commit 7f60ef8

Please sign in to comment.