Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.1] Display binary data even if text data is expected #18502

Closed
Closed
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 lib/galaxy/datatypes/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ def display_data(
):
headers = kwd.get("headers", {})
if preview:
with compression_utils.get_fileobj(dataset.get_file_name()) as fh:
with compression_utils.get_fileobj(dataset.get_file_name(), "rb") as fh:
max_peek_size = 1000000 # 1 MB
if os.stat(dataset.get_file_name()).st_size < max_peek_size:
mime = "text/plain"
Expand Down
6 changes: 3 additions & 3 deletions lib/galaxy/datatypes/tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ def get_chunk(self, trans, dataset: HasFileName, offset: int = 0, ck_size: Optio
)

def _read_chunk(self, trans, dataset: HasFileName, offset: int, ck_size: Optional[int] = None):
with compression_utils.get_fileobj(dataset.get_file_name()) as f:
with compression_utils.get_fileobj(dataset.get_file_name(), "rb") as f:
f.seek(offset)
ck_data = f.read(ck_size or trans.app.config.display_chunk_size)
if ck_data and ck_data[-1] != "\n":
if ck_data and ck_data[-1] != b"\n":
cursor = f.read(1)
while cursor and cursor != "\n":
while cursor and cursor != b"\n":
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading single chars until you hit a newline was never ideal, but with a binary file this could potentially take a really long time, couldn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arg, yes, we're not reading from from the chunk ...

ck_data += cursor
cursor = f.read(1)
last_read = f.tell()
Expand Down
Loading