Skip to content

Commit

Permalink
fix: Make compiler more robust to bad messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Dec 3, 2021
1 parent 021bce2 commit fc3f51d
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions process/management/commands/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,35 @@ def __init__(self):
def process(self, connection, channel, delivery_tag, body):
input_message = json.loads(body.decode("utf8"))

try:
self.logger.debug("Received message %s", input_message)
self.logger.debug("Received message %s", input_message)

collection = None
collection_file = None
collection = None
collection_file = None

if "collection_id" in input_message:
# received message from collection closed api endpoint
if "collection_id" in input_message:
# received message from collection closed api endpoint
try:
collection = Collection.objects.get(pk=input_message["collection_id"])
else:
# received message from regular file processing
except Collection.DoesNotExist:
self.logger.exception("Collection not found. It might have been deleted.")
self._clean_thread_resources()
return
else:
# received message from regular file processing
try:
collection_file = CollectionFile.objects.prefetch_related("collection").get(
pk=input_message["collection_file_id"]
)
except CollectionFile.DoesNotExist:
self.logger.exception("CollectionFile not found. It might have been deleted.")
self._clean_thread_resources()
return

collection = collection_file.collection
collection = collection_file.collection

self._ack(connection, channel, delivery_tag)
self._ack(connection, channel, delivery_tag)

try:
if compilable(collection.id):
if collection.data_type and collection.data_type["format"] == Collection.DataTypes.RELEASE_PACKAGE:
real_files_count = CollectionFile.objects.filter(collection=collection).count()
Expand Down

0 comments on commit fc3f51d

Please sign in to comment.