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

utils/archive: support for detecting archive files without proper extensions #5997

Open
clebergnu opened this issue Aug 4, 2024 · 0 comments
Labels
customer:QEMU Requirements/issues raised by the QEMU project enhancement

Comments

@clebergnu
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Currently, support for opening archive files is based on a table that maps extensions to some metadata like them either them being a "zip" or a "tar" file. This does not take into consideration the other types of archive supported, and also fails to support files without extensions.

Describe the solution you'd like
It should be possible to open an archive file such as:

$ tar cf /tmp/tarfile /etc/issue

And while is_archive() behaves as expected:

>>> archive.is_archive('/tmp/tarfile')
True

The more important extract() does not:

archive.extract('/tmp/tarfile', '/tmp')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/cleber/src/avocado/avocado/avocado/utils/archive.py", line 366, in uncompress
    with ArchiveFile.open(filename) as x:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/cleber/src/avocado/avocado/avocado/utils/archive.py", line 225, in open
    return cls(filename, mode)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/cleber/src/avocado/avocado/avocado/utils/archive.py", line 205, in __init__
    raise ArchiveException("file is not an archive")
avocado.utils.archive.ArchiveException: file is not an archive

Describe alternatives you've considered
Requiring users to properly name files, but this is sometimes not possible or just an annoyance. Also the extension table is really not mapping well to the supported archive formats.

@clebergnu clebergnu added enhancement customer:QEMU Requirements/issues raised by the QEMU project labels Aug 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer:QEMU Requirements/issues raised by the QEMU project enhancement
Projects
Status: Short Term (Current Q) Backlog
Development

No branches or pull requests

1 participant