Merge "Handle file removal concurrency"

This commit is contained in:
Zuul 2021-11-03 17:59:11 +00:00 committed by Gerrit Code Review
commit 7af23e5159

View File

@ -124,9 +124,13 @@ def make_dir(dirname):
def remove_file(filename):
if os.path.isfile(filename):
LOG.debug("Remove file: '%s'", filename)
try:
os.unlink(filename)
return True
except FileNotFoundError:
LOG.debug("File concurrently removed: '%s'", filename)
else:
LOG.debug("File removed: '%s'", filename)
return True
return False