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

minor: Add Zip decompression #917

Closed
wants to merge 1 commit into from
Closed

minor: Add Zip decompression #917

wants to merge 1 commit into from

Conversation

vipulgupta2048
Copy link
Member

Add zip decompression in leviathan to unblock autohat tests migration.

Signed-off-by: Vipul Gupta (@vipulgupta2048) [email protected]

@vipulgupta2048 vipulgupta2048 linked an issue Dec 23, 2022 that may be closed by this pull request
@balena-ci balena-ci enabled auto-merge December 23, 2022 18:51
@balena-ci balena-ci disabled auto-merge January 14, 2023 15:27
@vipulgupta2048
Copy link
Member Author

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.

Copy link
Contributor

@jakogut jakogut left a 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);
Copy link
Contributor

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')
Copy link
Contributor

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) {
Copy link
Contributor

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?

@vipulgupta2048
Copy link
Member Author

vipulgupta2048 commented Apr 19, 2023

@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.

@vipulgupta2048 vipulgupta2048 marked this pull request as draft April 19, 2023 08:25
@vipulgupta2048
Copy link
Member Author

Closing in favor of #1062
cc: @jakogut if you would like to review that one

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.

Support zip decompression
2 participants