Allow images to be extracted from StuffIt, tarball, gzip, and 7z#789
Conversation
| {% if file["archive_contents"] %} | ||
| <form action="/files/extract_image" method="post"> | ||
| <input name="archive_file" type="hidden" value="{{ file['name'] }}"> | ||
| {% set pipe = joiner("|") %} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.)
rdmark
left a comment
There was a problem hiding this comment.
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.
Allows archives in the
imagesdir 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.runmodule which can be used in place of the existing calls to asyncio.run and subprocess.run found throughout the application.