feat(cicero-core): compress .cta archives with DEFLATE#872
Open
yashhzd wants to merge 1 commit intoaccordproject:mainfrom
Open
feat(cicero-core): compress .cta archives with DEFLATE#872yashhzd wants to merge 1 commit intoaccordproject:mainfrom
yashhzd wants to merge 1 commit intoaccordproject:mainfrom
Conversation
…t coverage Enable DEFLATE compression (level 6) in TemplateSaver.toArchive() for .cta archive files. Previously archives used STORE (no compression), producing files roughly 2x larger than necessary. Changes: - Set compression to DEFLATE in JSZip generateAsync() call - Simplify async return by removing redundant Promise wrapping - Remove unused archiver devDependency (never imported in codebase) - Expand TemplateSaver test coverage from 2 to 16 test cases: compression verification, archive structure validation, backward compatibility with uncompressed archives, roundtrip content preservation, and template-with-logo handling Backward compatibility: JSZip.loadAsync() transparently handles both STORE and DEFLATE archives, so existing uncompressed .cta files continue to load without any changes. Closes accordproject#678 Signed-off-by: Yash Goel <yashgoel0810@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #678
.ctatemplate archives are currently created withSTORE(no compression), producing files roughly 2x larger than necessary. As noted by @jeromesimeon, JSZip defaults toSTOREwhen nocompressionoption is passed.This PR enables
DEFLATEcompression inTemplateSaver.toArchive()and expands test coverage from 2 to 16 test cases.Changes
1. Enable DEFLATE compression
Level 6 provides a good balance between compression ratio and speed (level 9 is only marginally smaller but significantly slower).
2. Clean up redundant Promise wrapping
The previous code wrapped
generateAsync's result in an unnecessaryPromise.resolve().then()chain that just returned the value unchanged. Simplified to a direct return.3. Remove unused
archiverdevDependencyThe
archiverpackage (v5.3.1) was declared indevDependenciesbut never imported or used anywhere in the codebase. Removed to reduce install size and maintenance burden.4. Expand TemplateSaver test coverage (2 → 16 tests)
TemplateSaverpreviously had only 2 tests. This PR adds 14 new tests across 4 categories:Compression tests (2):
\x08\x00)Archive structure tests (7):
text/grammar.tem.mdpresent and non-emptytext/sample.mdpresentsignature.jsonabsent when template is unsignedBackward compatibility tests (3):
Template.fromArchive()with matching identifier and model countLogo test (1):
logo.pngincluded as binary in archiveAll 192 tests pass (including 16 TemplateSaver tests). 7 pre-existing pending tests (template signing) unaffected.
Backward Compatibility
This is not a breaking change. JSZip's
loadAsync()transparently handles bothSTOREandDEFLATEarchives. The test suite explicitly verifies that:Template.fromArchive().ctafiles continue to load without errorAs @mttrbrts asked in the original issue — this is safe because the reading side (JSZip) auto-detects compression format.
Author Checklist