Skip to content

Commit 73f277c

Browse files
committed
fix(wiper): Delete derived collections first
1 parent 8bcc7df commit 73f277c

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

process/management/commands/wiper.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ def handle(self, *args, **options):
2525
)
2626

2727

28-
def callback(client_state, channel, method, properties, input_message):
29-
collection_id = input_message["collection_id"]
30-
28+
def delete_collection(collection_id):
3129
tables = [
3230
("record", None), # references collection_file_item
3331
("release", None), # references collection_file_item
@@ -67,4 +65,20 @@ def callback(client_state, channel, method, properties, input_message):
6765

6866
Collection.objects.filter(pk=collection_id).delete()
6967

68+
69+
def callback(client_state, channel, method, properties, input_message):
70+
collection_id = input_message["collection_id"]
71+
72+
try:
73+
collection = Collection.objects.get(pk=collection_id)
74+
except Collection.DoesNotExist:
75+
pass
76+
else:
77+
if compiled_collection := collection.get_compiled_collection():
78+
delete_collection(compiled_collection.pk)
79+
if upgraded_collection := collection.get_upgraded_collection():
80+
delete_collection(upgraded_collection.pk)
81+
82+
delete_collection(collection_id)
83+
7084
ack(client_state, channel, method.delivery_tag)

0 commit comments

Comments
 (0)