-
Notifications
You must be signed in to change notification settings - Fork 6
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
minor: Add Zip decompression #917
Conversation
Signed-off-by: Vipul Gupta (@vipulgupta2048) <[email protected]>
With #965, image uploads massively changing and hence the need for any compression on client side has been deprecated since Worker will be handling that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume the purpose of this PR is to support zipped images as downloaded from the dashboard? It looks like a lot of the changes here were indentation, it's difficult to discern what is simply formatting, and what's actual code changes. Can you summarize the changes made, or break up the commit into more manageable chunks?
|
||
await fs.read(await fs.open(filepath, 'r'), buf, 0, 4, 0) | ||
|
||
return buf[0] === 0x50 && buf[1] === 0x4B && (buf[2] === 0x03 || buf[2] === 0x05 || buf[2] === 0x07) && (buf[3] === 0x04 || buf[3] === 0x06 || buf[3] === 0x08); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is too long and it hurts readability. It would also be helpful to have a comment documenting the signature we're checking against (or linking to a specification or reference of some sort) rather than a bunch of magic numbers.
@@ -65,6 +65,7 @@ const { join } = require('path'); | |||
const tmp = require('tmp'); | |||
const pipeline = Bluebird.promisify(require('stream').pipeline); | |||
const zlib = require('zlib'); | |||
const extractZip = requrie('extract-zip') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a typo, does this still work? Was it tested?
@@ -138,6 +139,13 @@ async function isGzip(filePath) { | |||
return buf[0] === 0x1f && buf[1] === 0x8b && buf[2] === 0x08; | |||
} | |||
|
|||
|
|||
async function isZip(filepath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this function duplicated?
@jakogut That is correct. This allows us to use downloaded images directly from Jenkins or balena API. I reopened it not with the purpose to merge it. Instead, this functionality needs to be in the leviathan worker for v3.0. With it around, I am trying to find out functionality we have already built and can be re-used in leivathan worker. Should have mentioned it somewhere before hand. Will take your review into account when I open the PR again. |
Add zip decompression in leviathan to unblock autohat tests migration.
Signed-off-by: Vipul Gupta (@vipulgupta2048) [email protected]