MySQL still doesn't allow us to have empty IN clauses.
This commit is contained in:
parent
6ca0115b5e
commit
dc5ee43a3a
1 changed files with 26 additions and 21 deletions
|
@ -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
|
# 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),
|
orphaned_from_candidates = list(orphaned_storage_query(ImageStorage.select(ImageStorage.id),
|
||||||
storage_id_whitelist))
|
storage_id_whitelist))
|
||||||
|
|
||||||
|
if len(orphaned_from_candidates) > 0:
|
||||||
derived_to_remove = (ImageStorage
|
derived_to_remove = (ImageStorage
|
||||||
.select(ImageStorage.id)
|
.select(ImageStorage.id)
|
||||||
.join(DerivedImageStorage,
|
.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())
|
paths_to_remove = placements_query_to_paths_set(placements_to_remove.clone())
|
||||||
|
|
||||||
# Remove the placements for orphaned storages
|
# 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
|
(ImageStoragePlacement
|
||||||
.delete()
|
.delete()
|
||||||
.where(ImageStoragePlacement.id << list(placements_subquery))
|
.where(ImageStoragePlacement.id << list(placements_subquery))
|
||||||
.execute())
|
.execute())
|
||||||
|
|
||||||
# Remove the all orphaned storages
|
# Remove the all orphaned storages
|
||||||
|
orphaned_storages = list(orphaned_storage_query(ImageStorage.select(ImageStorage.id),
|
||||||
|
storage_id_whitelist))
|
||||||
|
if len(orphaned_storages) > 0:
|
||||||
(ImageStorage
|
(ImageStorage
|
||||||
.delete()
|
.delete()
|
||||||
.where(ImageStorage.id << list(orphaned_storage_query(ImageStorage.select(ImageStorage.id),
|
.where(ImageStorage.id << orphaned_storages)
|
||||||
storage_id_whitelist)))
|
|
||||||
.execute())
|
.execute())
|
||||||
|
|
||||||
# Delete the actual blob storage
|
# Delete the actual blob storage
|
||||||
|
|
Reference in a new issue