Skip to content
This repository was archived by the owner on Jun 13, 2025. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions upload/views/uploads.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import uuid
from typing import Any, Callable, Dict

from django.http import HttpRequest, HttpResponseNotAllowed
Expand Down Expand Up @@ -56,6 +57,18 @@ def create_upload(
else None
)
archive_service = ArchiveService(repository)
# only Shelter requests are allowed to set their own `storage_path`
serializer.validated_data["external_id"] = uuid.uuid4()
if serializer.validated_data["storage_path"] is None or not is_shelter_request:
path = MinioEndpoints.raw_with_upload_id.get_path(
version="v4",
date=timezone.now().strftime("%Y-%m-%d"),
repo_hash=archive_service.storage_hash,
commit_sha=commit.commitid,
reportid=report.external_id,
uploadid=serializer.validated_data["external_id"],
)
serializer.validated_data["storage_path"] = path
# Create upload record
instance: ReportSession = serializer.save(
report_id=report.id, upload_extras={"format_version": "v1"}, state="started"
Expand All @@ -72,18 +85,6 @@ def create_upload(
report_type=report.report_type,
)

# only Shelter requests are allowed to set their own `storage_path`
if instance.storage_path is None or not is_shelter_request:
path = MinioEndpoints.raw_with_upload_id.get_path(
version="v4",
date=timezone.now().strftime("%Y-%m-%d"),
repo_hash=archive_service.storage_hash,
commit_sha=commit.commitid,
reportid=report.external_id,
uploadid=instance.external_id,
)
instance.storage_path = path
instance.save()
trigger_upload_task(repository, commit.commitid, instance, report)
activate_repo(repository)
send_analytics_data(commit, instance, version, analytics_token)
Expand Down
Loading