Ignore a filenotfound error that happens during folder removal on windows despite exists() succeeding

This commit is contained in:
Kovid Goyal 2024-01-30 12:23:33 +05:30
parent 0c66368c9e
commit e1956f3cff
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -284,6 +284,12 @@ def copy_tree(
if delete_source and os.path.exists(make_long_path_useable(src)):
try:
shutil.rmtree(make_long_path_useable(src))
except FileNotFoundError:
# some kind of delayed folder removal on handle close on Windows? Or exists() is succeeding but
# rmdir() is failing? Or something deleted the
# folder between the call to exists() and rmtree(). Windows is full
# of nanny programs that keep users safe from "themselves".
pass
except OSError:
if iswindows:
time.sleep(WINDOWS_SLEEP_FOR_RETRY_TIME)