Merge "Check to make sure the incomplete file exists before moving it during rollback. Fixes bug #888241."

This commit is contained in:
Jenkins 2011-11-23 17:41:21 +00:00 committed by Gerrit Code Review
commit 105f792fa1

View File

@ -306,11 +306,14 @@ class Driver(base.Driver):
def rollback(e):
with self.get_db() as db:
invalid_path = self.get_image_filepath(image_id, 'invalid')
logger.debug(_("Fetch of cache file failed, rolling back by "
"moving '%(incomplete_path)s' to "
"'%(invalid_path)s'") % locals())
os.rename(incomplete_path, invalid_path)
if os.path.exists(incomplete_path):
invalid_path = self.get_image_filepath(image_id, 'invalid')
logger.debug(_("Fetch of cache file failed, rolling back "
"by moving '%(incomplete_path)s' to "
"'%(invalid_path)s'") % locals())
os.rename(incomplete_path, invalid_path)
db.execute("""DELETE FROM cached_images
WHERE image_id = ?""", (image_id, ))
db.commit()