Handle non-UTF-8 filenames in cache directory when expiring

This commit is contained in:
Kovid Goyal 2019-11-20 08:28:54 +05:30
parent 428957543c
commit d57626c043
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -54,8 +54,11 @@ def safe_makedirs(path):
def robust_rmtree(x):
retries = 2 if iswindows else 1 # retry on windows to get around the idiotic mandatory file locking
for i in range(retries):
try:
try:
rmtree(x)
except UnicodeDecodeError:
rmtree(as_bytes(x))
return True
except EnvironmentError:
time.sleep(0.1)