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

fix(rosetta): infuse incorrectly handles compressed assemblies #3669

Merged
merged 1 commit into from
Jul 22, 2022

Conversation

kaizencc
Copy link
Contributor

The behavior of rosetta infuse was incorrectly handled before. infuse would always overwrite the .jsii file with the uncompressed assembly. This PR fixes that behavior by detecting whether or not there is a compressed file in the directory, and compressing if that is the case.

There are two alternative solutions I considered, primarily because I'm concerned that looking up the location of the compressed assembly can be considered a leaky abstraction:

  • loading and looking into the contents of .jsii again to determine whether or not it is a file redirect. I did not choose this option as it involves additional loading, which will slow things down.
  • We can expand the LoadedAssembly type to include information on whether or not the assembly was originally compressed. Then pass that into the replaceAssembly() function. I ultimately decided against this because it would involve changing the function signature of all loadAssemblyFromXxx functions. It's both a breaking change, and unnecessary clutter for a single use case.

Based on the reasoning above, I think what is included in this PR makes the most sense: expose an independent function, compressedAssemblyExists, that returns whether or not there is a file located at SPEC_FILE_NAME_COMPRESSED.


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Jul 21, 2022
{ compress = false }: { compress?: boolean } = {},
) {
writeAssembly(directory, _fingerprint(assembly), { compress });
export function replaceAssembly(assembly: spec.Assembly, directory: string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a breaking change :(. If we must add the { compress = false }: { compress?: boolean } = {} option in again, then fine. I really don't want to though, because in my mind, this was a bit of a stealth mode release and its unlikely that this revert actually breaks any users. Especially because the prior behavior was incorrect, and I would simply ignore the property if we have to keep it in...

Copy link
Contributor

Choose a reason for hiding this comment

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

You could also just change the default behavior for compress -- JavaScript does not require default values are constants/literals, it can be a function call result...

@mergify
Copy link
Contributor

mergify bot commented Jul 22, 2022

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify bot added the pr/ready-to-merge This PR is ready to be merged. label Jul 22, 2022
@mergify
Copy link
Contributor

mergify bot commented Jul 22, 2022

Merging (with squash)...

@mergify mergify bot merged commit a5bd219 into main Jul 22, 2022
@mergify mergify bot deleted the conroy/save-fix branch July 22, 2022 07:50
@mergify mergify bot removed the pr/ready-to-merge This PR is ready to be merged. label Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contribution/core This is a PR that came from AWS.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants