MySQL still doesn't allow us to have empty IN clauses.

This commit is contained in:
Jake Moshenko 2014-10-17 17:49:18 -04:00
parent 6ca0115b5e
commit dc5ee43a3a

View file

@ -1423,6 +1423,8 @@ def garbage_collect_storage(storage_id_whitelist):
# Find out which derived storages will be removed, and add them to the whitelist
orphaned_from_candidates = list(orphaned_storage_query(ImageStorage.select(ImageStorage.id),
storage_id_whitelist))
if len(orphaned_from_candidates) > 0:
derived_to_remove = (ImageStorage
.select(ImageStorage.id)
.join(DerivedImageStorage,
@ -1448,17 +1450,20 @@ def garbage_collect_storage(storage_id_whitelist):
paths_to_remove = placements_query_to_paths_set(placements_to_remove.clone())
# Remove the placements for orphaned storages
placements_subquery = placements_to_remove.clone().select(ImageStoragePlacement.id)
placements_subquery = list(placements_to_remove.clone().select(ImageStoragePlacement.id))
if len(placements_subquery) > 0:
(ImageStoragePlacement
.delete()
.where(ImageStoragePlacement.id << list(placements_subquery))
.execute())
# Remove the all orphaned storages
orphaned_storages = list(orphaned_storage_query(ImageStorage.select(ImageStorage.id),
storage_id_whitelist))
if len(orphaned_storages) > 0:
(ImageStorage
.delete()
.where(ImageStorage.id << list(orphaned_storage_query(ImageStorage.select(ImageStorage.id),
storage_id_whitelist)))
.where(ImageStorage.id << orphaned_storages)
.execute())
# Delete the actual blob storage