Improve deleting-missing-backup exception handling

When deleting missing backup, OSError could be checked to make
sure that the actual error was that the file does not exist.

Change-Id: I988370d702d87acde534670575d599159b48c58b
Signed-off-by: Xiaojun Liao <xiaojunliao85@gmail.com>
This commit is contained in:
Xiaojun Liao 2017-10-30 16:58:33 +08:00
parent 9dc606da52
commit 851b60d89d

@ -17,6 +17,7 @@
"""Implementation of a backup service that uses a posix filesystem as the
backend."""
import errno
import os
import os.path
import stat
@ -129,8 +130,10 @@ class PosixBackupDriver(chunkeddriver.ChunkedBackupDriver):
path = os.path.join(self.backup_path, container, object_name)
try:
os.remove(path)
except OSError:
pass
except OSError as e:
# ignore exception if path does not exsit
if e.errno != errno.ENOENT:
raise
def _generate_object_name_prefix(self, backup):
timestamp = timeutils.utcnow().strftime("%Y%m%d%H%M%S")