-
-
Notifications
You must be signed in to change notification settings - Fork 274
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
Log file inside zip file erroneously guessed as "tar" instead of text #2316
Comments
Hi @krackout! Thanks for filing this issue. Please provide some sample data, so that we can reproduce this. We might not be able to fix it otherwise. |
Inside somelogs.zip file, there's a freshclam.log which produces the error. |
Seeing the same thing here, repro: echo "hiya" > test.log
zip test.zip test.log
vd -N test.zip Then hitting Traceback (most recent call last):
File "/home/aj/.local/pipx/venvs/visidata/lib/python3.12/site-packages/visidata/threads.py", line 220, in _toplevelTryFunc
t.status = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/home/aj/.local/pipx/venvs/visidata/lib/python3.12/site-packages/visidata/sheets.py", line 260, in reload
self.loader()
File "/home/aj/.local/pipx/venvs/visidata/lib/python3.12/site-packages/visidata/sheets.py", line 285, in loader
for r in self.iterload():
File "/home/aj/.local/pipx/venvs/visidata/lib/python3.12/site-packages/visidata/loaders/archive.py", line 140, in iterload
with tarfile.open(name=str(self.source)) as tf:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/tarfile.py", line 1808, in open
raise ReadError(f"file could not be opened successfully:\n{error_msgs_summary}")
tarfile.ReadError: file could not be opened successfully:
- method gz: ReadError('not a gzip file')
- method bz2: ReadError('not a bzip2 file')
- method xz: ReadError('not an lzma file')
- method tar: ReadError('truncated header') Bisect tells me that this started in eb9d9c4. If I use
Guessing doesn't work for a tar file named |
Thanks for investigating! =) Wrt that commit, for any fixes, we'll also have to check up on this behaviour: #1978 |
Good call, thanks! Ok repro matrix time 😅 . There are a few candidates for that line: if tarfile.is_tarfile(p):
if tarfile.is_tarfile(p.fp):
if tarfile.is_tarfile(p.open_bytes()): And a few cases to check:
And from some testing the results look like... if tarfile.is_tarfile(p):
if tarfile.is_tarfile(p.fp):
if tarfile.is_tarfile(p.open_bytes()):
So I think none of the options I listed are perfect, but |
I think it should be rare enough that we can punt on it for now. Ultimately we should head towards filetype being composable, e.g. |
It must be an edge case indeed; I supposed it would be easy to fix, since it worked on v2.11. |
v2.11 did not have the filetype guesser logic! That's why the behaviour changed. =) |
I've been sitting on a mostly-finished patch that addresses the issue of Currently, visidata saves stdin data into a If there's interest, I can put up what I've got as a starting point. But it needs to be finished, and then tested thoroughly. I can't do that in the near future. |
I would love to see that, @midichef. I don't have time myself right now either, but maybe it will inspire another enterprising VisiDatan to kick the tires on it. |
I'm curious too. I would definitely need some time to spin up on the changes and ripple effects. Happy to kick the tires and work through issues though. I'm onboard with the motivation for sure, so it's very cool that you've already got something started! ❤️ |
@saulpw Apparently you misunderstood. It's a text file with .log extension, inside a zip file. The text/log file is guessed erroneously as tar, no tar involved. |
@krackout I was being a little cheeky, the 'you' here was referring to the hypothetical user for a tar file within an archive:
|
An update to my comment a couple of months ago:
I've been prioritizing fixing Visidata bugs, but now I can resume work on this feature. I will likely have a workable version ready within a week. |
Log file inside zip file erroneously guessed as "tar" instead of text. Visidata version 3.0.2.
On 2.11 it's correctly opened as text.
The text was updated successfully, but these errors were encountered: