Skip to content

Allow images to be extracted from StuffIt, tarball, gzip, and 7z#789

Merged
rdmark merged 1 commit intoPiSCSI:developfrom
nucleogenic:webui-add-extra-archive-format-support
Aug 19, 2022
Merged

Allow images to be extracted from StuffIt, tarball, gzip, and 7z#789
rdmark merged 1 commit intoPiSCSI:developfrom
nucleogenic:webui-add-extra-archive-format-support

Conversation

@nucleogenic
Copy link
Copy Markdown
Member

Allows archives in the images dir to be extracted if they are in StuffIt, tarball, gzip or 7z formats, in addition to zip files. This can be expanded to any format supported by The Unarchiver; however, I've whitelisted the formats that have been tested.

These changes serve as the prelude to support for extracting archives with their resource forks preserved (#630), which is currently a work in progress.

I have extracted command execution/logging to a new util.run module which can be used in place of the existing calls to asyncio.run and subprocess.run found throughout the application.

{% if file["archive_contents"] %}
<form action="/files/extract_image" method="post">
<input name="archive_file" type="hidden" value="{{ file['name'] }}">
{% set pipe = joiner("|") %}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is a neat trick, I haven't seen this syntax in jinja2 before. So how does this logic work exactly? It iterates through the archive files and filters it to create the path for each file?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

joiner returns the delimiter on every call, except the first, so:

{{ pipe() }}{{ member["path"] }}

gives us: value, then |value thereafter, to create the delimited string, e.g.

<input name="archive_members" type="hidden" value="PropsTest.hds|PropsTest.hds.properties">

(I couldn't make the join filter work in this case, as the value needed is nested inside a dict.)

Copy link
Copy Markdown
Member

@rdmark rdmark left a comment

Choose a reason for hiding this comment

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

At a code review level it looks great, no concerns. I haven't actually dynamically tested it yet, but feel free to merge when you're ready and we can roll forward if something breaks.

@rdmark rdmark merged commit 161bd32 into PiSCSI:develop Aug 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants