-
Notifications
You must be signed in to change notification settings - Fork 16
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
Conversation
This is related to #89 |
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.
Nice optimization 👍
pkg/archive/archive.go
Outdated
@@ -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. |
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.
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.
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.
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
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.
Thank you for making the change 👌
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