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

Compressed resource optimization #93

Merged
merged 5 commits into from
Jul 3, 2024

Conversation

chocolatkey
Copy link
Member

@chocolatkey chocolatkey commented Jun 4, 2024

This enhancement allow for resources to be read in their compressed form, which usually applies to most if not all resources in any ZIP-based format (primarily EPUB). This saves CPU time because any modern web browser is capable of decompressing a deflate-encoded resource, so the raw contents of the ZIP can be directly proxied to any web client. Closes #89

@chocolatkey chocolatkey marked this pull request as ready for review June 17, 2024 07:16
@chocolatkey chocolatkey requested a review from mickael-menu June 17, 2024 07:18
@HadrienGardeur
Copy link
Member

This is related to #89

Copy link
Member

@mickael-menu mickael-menu left a comment

Choose a reason for hiding this comment

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

Nice optimization 👍

@@ -55,9 +55,10 @@ type Entry interface {
Path() string // Absolute path to the entry in the archive.
Length() uint64 // Uncompressed data length.
CompressedLength() uint64 // Compressed data length.
CompressedAs(compressionMethod uint16) bool // Whether the entry is compressed using the given method.
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the 8 value for deflate only relevant in the context of a ZIP? Theoretically we could use Archive for a CBR/RAR file as well.

To remove any ambiguity, what do you think of adding an explicit enum with Deflate case in the toolkit instead of using ints?

Having CompressionMethod() CompressionMethod might be more convenient too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Technically, the latest version of the ZIP spec supports other compression formats as well. I think the correct term would be that the EPUB standard only supports modes 0 and 8. I think it's worth keeping the door open for other compression modes for other container formats that we might support, or whose specs may change to support other methods in the future.

I've added your suggested CompressionMethod enum

Copy link
Member

@mickael-menu mickael-menu left a comment

Choose a reason for hiding this comment

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

Thank you for making the change 👌

@chocolatkey chocolatkey merged commit cbc0d22 into develop Jul 3, 2024
1 check passed
@chocolatkey chocolatkey deleted the compressed-resource-optimization branch July 3, 2024 12:04
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.

Add ability to read raw compressed archive entries
3 participants