Skip to content

Commit

Permalink
Remove charset-normalizer, replace with BytesIO
Browse files Browse the repository at this point in the history
This worked occasionally.
Update CHANGELOG.md
  • Loading branch information
jameskr97 committed Oct 31, 2021
1 parent 923ad94 commit d7523d7
Show file tree
Hide file tree
Showing 4 changed files with 184 additions and 169 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.3.1] - 2021-10-29
### Removed
- `charset-normalizer`: Switched to using BytesIO

### Fixed
- Fixed web minidump upload to work with zero attachments
- Fixed web crash list from showing all rows as "Processing"
Expand Down
10 changes: 4 additions & 6 deletions crashserver/webapp/api.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import itertools
import operator
import io

from flask import Blueprint, request, render_template, flash, redirect, make_response
import charset_normalizer as char_norm
from sqlalchemy import func
from loguru import logger
from flask_login import login_required
Expand Down Expand Up @@ -53,18 +53,16 @@ def upload_minidump(project):
def upload_symbol(project, version):
symbol_file = request.files.get("symbol_file")

# Use charset_normalizer to get a readable version of the text.
symbol_file_bytes = symbol_file.stream.read()
char_res = char_norm.from_bytes(symbol_file_bytes)
decoded = char_res.best().output()
first_line_str = decoded[: decoded.find("\n".encode())].decode("utf-8")
with io.BytesIO(symbol_file_bytes) as f:
first_line_str = f.readline().decode("utf-8")

# Get relevant module info from first line of file
symbol_data = SymbolData.from_module_line(first_line_str)
symbol_data.app_version = version
symbol_file.stream.seek(0)

return ops.symbol_upload(db.session, project, decoded, symbol_data)
return ops.symbol_upload(db.session, project, symbol_file_bytes, symbol_data)


@api.route("/webapi/symbols/<project_id>")
Expand Down
Loading

0 comments on commit d7523d7

Please sign in to comment.