Skip to content

Commit 6703e65

Browse files
ref: remove dead code in models.eventattachment (#72799)
this fixes type checking in this module when BaseManager becomes checked <!-- Describe your PR here. -->
1 parent 7bf1ba4 commit 6703e65

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

src/sentry/models/eventattachment.py

+10-26
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
from typing import IO, Any
88

99
import zstandard
10-
from django.conf import settings
1110
from django.core.cache import cache
1211
from django.core.exceptions import ObjectDoesNotExist
1312
from django.db import models
@@ -169,7 +168,7 @@ def getfile(self) -> IO[bytes]:
169168

170169
@classmethod
171170
def putfile(cls, project_id: int, attachment: CachedAttachment) -> PutfileResult:
172-
from sentry.models.files import File, FileBlob
171+
from sentry.models.files import FileBlob
173172

174173
content_type = normalize_content_type(attachment.content_type, attachment.name)
175174
data = attachment.data
@@ -179,34 +178,19 @@ def putfile(cls, project_id: int, attachment: CachedAttachment) -> PutfileResult
179178

180179
blob = BytesIO(data)
181180

182-
# NOTE: we still keep the old code around for a while before complete removing it
183-
store_blobs = True
181+
size, checksum = get_size_and_checksum(blob)
184182

185-
if store_blobs:
186-
size, checksum = get_size_and_checksum(blob)
187-
188-
if can_store_inline(data) and in_random_rollout("eventattachments.store-small-inline"):
189-
blob_path = ":" + data.decode()
190-
else:
191-
blob_path = "eventattachments/v1/" + FileBlob.generate_unique_path()
192-
193-
storage = get_storage()
194-
compressed_blob = BytesIO(zstandard.compress(data))
195-
storage.save(blob_path, compressed_blob)
196-
197-
return PutfileResult(
198-
content_type=content_type, size=size, sha1=checksum, blob_path=blob_path
199-
)
183+
if can_store_inline(data) and in_random_rollout("eventattachments.store-small-inline"):
184+
blob_path = ":" + data.decode()
185+
else:
186+
blob_path = "eventattachments/v1/" + FileBlob.generate_unique_path()
200187

201-
file = File.objects.create(
202-
name=attachment.name,
203-
type=attachment.type,
204-
headers={"Content-Type": content_type},
205-
)
206-
file.putfile(blob, blob_size=settings.SENTRY_ATTACHMENT_BLOB_SIZE)
188+
storage = get_storage()
189+
compressed_blob = BytesIO(zstandard.compress(data))
190+
storage.save(blob_path, compressed_blob)
207191

208192
return PutfileResult(
209-
content_type=content_type, size=file.size, sha1=file.checksum, file_id=file.id
193+
content_type=content_type, size=size, sha1=checksum, blob_path=blob_path
210194
)
211195

212196

0 commit comments

Comments
 (0)