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
Fix glance db migration failed on 031

In fact, the first where expression has filtered the duplicated locations,
and the second filters the locations which have more than 1 rows, so the
second result set is included in the first.
In DB2, if the boolean of where expression is true, it will throw error.
So remove the second where expression to fix glance db migration failed on 031.

Fixes bug #1287087

Change-Id: Id485b6d20696e989d10f3759011387137543918a
Merge "Catch exception when image cache pruning"
Merge "Fix glance db migration failed on 031"