Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dependencies = [
"mmh3>=4.0.0",
"msgspec>=0.19.0",
"msgpack>=1.2.1",
"objectstore-client>=0.1.11",
"objectstore-client>=0.1.13",
"openai>=1.3.5",
"orjson>=3.10.10",
"packaging>=24.1",
Expand Down
71 changes: 42 additions & 29 deletions src/sentry/models/debugfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,35 @@
OBJECTSTORE_MULTIPART_UPLOAD_PART_SIZE = 32 * 1024 * 1024 # 32 MiB


def _dif_file_extension(file_format: str, file_type: str | None) -> str:
if file_format == "breakpad":
return ".sym"
if file_format == "macho":
return ".debug" if file_type == "dbg" else ""
if file_format == "proguard":
return ".txt"
if file_format == "elf":
return "" if file_type == "exe" else ".debug"
if file_format == "pe":
return ".exe" if file_type == "exe" else ".dll"
if file_format == "pdb" or file_format == "portablepdb":
return ".pdb"
if file_format == "sourcebundle":
return ".src.zip"
if file_format == "wasm":
return ".wasm"
if file_format == "bcsymbolmap":
return ".bcsymbolmap"
if file_format == "uuidmap":
return ".plist"
if file_format == "il2cpp":
return ".json"
if file_format == "dartsymbolmap":
return ".json"

return ""


class BadDif(Exception):
pass

Expand Down Expand Up @@ -219,32 +248,7 @@ def file_type(self) -> str | None:

@property
def file_extension(self) -> str:
if self.file_format == "breakpad":
return ".sym"
if self.file_format == "macho":
return ".debug" if self.file_type == "dbg" else ""
if self.file_format == "proguard":
return ".txt"
if self.file_format == "elf":
return "" if self.file_type == "exe" else ".debug"
if self.file_format == "pe":
return ".exe" if self.file_type == "exe" else ".dll"
if self.file_format == "pdb" or self.file_format == "portablepdb":
return ".pdb"
if self.file_format == "sourcebundle":
return ".src.zip"
if self.file_format == "wasm":
return ".wasm"
if self.file_format == "bcsymbolmap":
return ".bcsymbolmap"
if self.file_format == "uuidmap":
return ".plist"
if self.file_format == "il2cpp":
return ".json"
if self.file_format == "dartsymbolmap":
return ".json"

return ""
return _dif_file_extension(self.file_format, self.file_type)

@property
def features(self) -> frozenset[str]:
Expand Down Expand Up @@ -402,9 +406,10 @@ def _upload_dif_to_objectstore(
fileobj: IO[bytes],
content_type: str,
file_size: int,
filename: str,
) -> str:
"""Uploads a debug file to Objectstore via parallel multipart upload, returning the key under which the file was uploaded."""
upload = session.initiate_multipart_upload(content_type=content_type)
upload = session.initiate_multipart_upload(content_type=content_type, filename=filename)

lock = threading.Lock()
num_parts = max(1, math.ceil(file_size / OBJECTSTORE_MULTIPART_UPLOAD_PART_SIZE))
Expand Down Expand Up @@ -523,11 +528,19 @@ def create_dif_from_id(

if features.has("organizations:objectstore-debugfiles-write", project.organization):
session = get_debug_files_session(project.organization_id, project.id)
file_type = (meta.data or {}).get("type")
filename = (
f"{os.path.basename(meta.debug_id)}{_dif_file_extension(meta.file_format, file_type)}"
)
if file is not None:
with file.getfile() as source:
storage_path = _upload_dif_to_objectstore(session, source, content_type, file_size)
storage_path = _upload_dif_to_objectstore(
session, source, content_type, file_size, filename
)
elif fileobj is not None:
storage_path = _upload_dif_to_objectstore(session, fileobj, content_type, file_size)
storage_path = _upload_dif_to_objectstore(
session, fileobj, content_type, file_size, filename
)
else:
raise RuntimeError("missing file object")

Expand Down
6 changes: 3 additions & 3 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading