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

[bugfix] handle extracting non-conformant zip files #649

Merged
merged 12 commits into from
Nov 17, 2024

Conversation

silentrald
Copy link
Contributor

@silentrald silentrald commented Nov 7, 2024

Issue described in discord

  • Change extract logic in import maps.
  • Remove jszip and node-stream-zip packages.

NOTES:

  • Used yauzl since that support non-conformant zip files and ram efficiency.
    • Caveats, may slow down zip extraction a little bit.
  • Added test on standard and the breaking map zip file.
  • Removed jszip in getting oculus manifest and I can't test it on my end.
  • Ready for review but will need to address some comments (BUG and NOTE).
  • Do we need to add more tests on big zip files, or a sample exported map files to see the memory usage?

@silentrald silentrald force-pushed the bugfix/non-standard-zip-extraction branch 2 times, most recently from 4b820ee to 01c405c Compare November 7, 2024 17:07
@silentrald silentrald changed the title [bugfix] use jszip instead of node-stream-zip for extracting map zip [bugfix] handle extracting non-conformant zip files Nov 7, 2024
@Zagrios
Copy link
Owner

Zagrios commented Nov 7, 2024

@silentrald I think you should go with yauzl 🤔 That way, we can also use it for the map import feature (and the zip files used when importing maps can be very large, so JSZip is a big no no in this case 😅)

@silentrald silentrald force-pushed the bugfix/non-standard-zip-extraction branch from 01c405c to 853da01 Compare November 8, 2024 02:45
@silentrald silentrald force-pushed the bugfix/non-standard-zip-extraction branch from 853da01 to dd08f41 Compare November 8, 2024 17:29
@silentrald silentrald marked this pull request as ready for review November 8, 2024 17:34
@Zagrios
Copy link
Owner

Zagrios commented Nov 11, 2024

@silentrald Everything seems to be working fine, except when I import multiple maps from a zip; it never ends:
image

I haven’t had time to debug, but the issue likely comes from these lines:

if (progress.current === progress.total) {
    completeNewFolder();
}

But, overall, the modifications seems a bit over engineered to me 😅
I have some ideas to simplify zip manipulations; I'll test them tomorrow to see if they're feasible and whether they actually make zip manipulations easier or not 😅 Otherwise we will probably stay like that 👌

@silentrald
Copy link
Contributor Author

@Zagrios yeah its a little bit over 😅 but was trying to not expose the yauzl module to everything so that its testable, so whenever a change happens, its should be isolated within zip.helpers.

Although I encountered that in coding and I suspect its in the Subject that I was using in importMaps. Sometimes it would drop next events and when that happens, the current != total occurs. I tested on mine and works with 89 songs but ill try to exhaustively add more songs to check if I can replicate.

@silentrald
Copy link
Contributor Author

silentrald commented Nov 12, 2024

Tested on around ~1,400 maps and its working fine 🤔 so its very weird that its not failing on my end

@silentrald
Copy link
Contributor Author

silentrald commented Nov 14, 2024

Notes:

  • Never though of generators 😯 but seems to be working, only had to set autoClose: false to make everything work as expected.
  • Just a weird bug with path.matchesGlob doesnt support escaping special characters, just used regex for this instead.
  • Maybe consider changing the name of YauzlZip to another name class like BsmExtractorZip since in theory, we own/control the function calls on that class. (In the future we can create BsmGeneratorZip if we need to).
  • sonarqube might need to ignore test case files.
    • Couldn't get sonar.exclusions=src/__tests__/** to work, might need to be configured in the hosting ig.

@silentrald silentrald force-pushed the bugfix/non-standard-zip-extraction branch 2 times, most recently from 87979f5 to e45a0d0 Compare November 16, 2024 01:39
Copy link

sonarqubecloud bot commented Nov 17, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

Copy link
Owner

@Zagrios Zagrios left a comment

Choose a reason for hiding this comment

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

🙌

@Zagrios
Copy link
Owner

Zagrios commented Nov 17, 2024

Thanks for the help @silentrald ! ❤️
Everything's working fine 👌
Merging 🚀

@Zagrios Zagrios merged commit f7f5f76 into Zagrios:master Nov 17, 2024
4 checks passed
@silentrald silentrald deleted the bugfix/non-standard-zip-extraction branch November 17, 2024 12:11
Zagrios added a commit that referenced this pull request Nov 25, 2024
…ction

[bugfix] handle extracting non-conformant zip files

(cherry picked from commit f7f5f76)
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.

2 participants