|
8 | 8 | import jsonschema |
9 | 9 | import orjson |
10 | 10 | from django.db import IntegrityError, router |
11 | | -from django.db.models import Case, Exists, IntegerField, Q, QuerySet, Value, When |
| 11 | +from django.db.models import Case, Exists, F, IntegerField, Q, QuerySet, Value, When |
12 | 12 | from django.http import Http404, HttpResponse, StreamingHttpResponse |
13 | 13 | from rest_framework import status |
14 | 14 | from rest_framework.request import Request |
@@ -515,7 +515,7 @@ def batch_assemble(project: Project, files: AssembleRequestPayload): |
515 | 515 | ) |
516 | 516 |
|
517 | 517 | for debug_file in existing_debug_files: |
518 | | - checksum = debug_file.checksum |
| 518 | + checksum = debug_file.nonnull_checksum |
519 | 519 | file = files_to_check.pop(checksum) |
520 | 520 | requested_debug_id = requested_debug_ids_by_checksum[checksum] |
521 | 521 |
|
@@ -633,6 +633,7 @@ def _is_proguard_reupload_clone_request( |
633 | 633 |
|
634 | 634 |
|
635 | 635 | class _DebugFileAnnotations(TypedDict): |
| 636 | + nonnull_checksum: str |
636 | 637 | requested_debug_id_match: int |
637 | 638 | proguard_clone_source_match: int |
638 | 639 |
|
@@ -677,8 +678,11 @@ def _find_existing_debug_files( |
677 | 678 | ProjectDebugFile.objects.filter( |
678 | 679 | project_id=project.id, |
679 | 680 | checksum__in=checksums, |
| 681 | + checksum__isnull=False, |
680 | 682 | ) |
681 | 683 | .annotate( |
| 684 | + # Mirror the filtered checksum into an annotated non-null field for type safety. |
| 685 | + nonnull_checksum=F("checksum"), |
682 | 686 | requested_debug_id_match=_build_requested_debug_id_match_annotation( |
683 | 687 | requested_debug_ids_by_checksum.items() |
684 | 688 | ), |
|
0 commit comments