Skip to content

Commit

Permalink
fix: Fix 9669106 for RabbitMQ code path
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmckinney committed Nov 25, 2021
1 parent c48c0e5 commit bd9ab55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions process/management/commands/api_loader.py
@@ -1,5 +1,7 @@
import json
import os.path

from django.conf import settings
from django.db import transaction
from django.db.models.functions import Now

Expand All @@ -23,6 +25,8 @@ def process(self, connection, channel, delivery_tag, body):
input_message = json.loads(body.decode("utf8"))
if input_message.get("errors", None) and not input_message.get("path", None):
input_message["path"] = input_message.get("url", None)
else:
input_message["path"] = os.path.join(settings.KINGFISHER_COLLECT_FILES_STORE, input_message["path"])

try:
collection = Collection.objects.get(id=input_message["collection_id"])
Expand Down
6 changes: 3 additions & 3 deletions process/views/api.py
Expand Up @@ -145,15 +145,15 @@ def close_collection(request):
def create_collection_file(request):
if request.method == "POST":
input = json.loads(request.body)
input["path"] = os.path.join(settings.KINGFISHER_COLLECT_FILES_STORE, input["path"])

if "collection_id" not in input or not ("path" in input or "errors" in input):
return HttpResponseBadRequest(
'Unable to parse input. Please provide {"path":"<some_path>", "collection_id":<some_number>}'
)

if not isfile(input["path"]):
return HttpResponseBadRequest("{} is not a file".format(input["path"]))
input_path = os.path.join(settings.KINGFISHER_COLLECT_FILES_STORE, input["path"])
if not isfile(input_path):
return HttpResponseBadRequest("{} is not a file".format(input_path))

try:
_publish(json_dumps(input), "api")
Expand Down

0 comments on commit bd9ab55

Please sign in to comment.