Catch exception when image cache pruning
If a cached image file does not exist, os.stat will throw an exception and the glance-cache-pruner can fail to run when it encounters the non-existent file. Adds a catch for the possible exception and sets file size to 0 so the glance-cache-pruner can successfully run and prune the cache. Change-Id: I55bee82c4a7aa0393d36c603c91adb8b44a7c7a3 Fixes: bug #1286240
This commit is contained in:
parent
9001bf283e
commit
c232ed76c7
@ -280,8 +280,12 @@ class Driver(base.Driver):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
path = self.get_image_filepath(image_id)
|
path = self.get_image_filepath(image_id)
|
||||||
file_info = os.stat(path)
|
try:
|
||||||
return image_id, file_info[stat.ST_SIZE]
|
file_info = os.stat(path)
|
||||||
|
size = file_info[stat.ST_SIZE]
|
||||||
|
except OSError:
|
||||||
|
size = 0
|
||||||
|
return image_id, size
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def open_for_write(self, image_id):
|
def open_for_write(self, image_id):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user