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

Optimize file checksums calculation #5112

Merged
merged 2 commits into from Dec 2, 2022

Conversation

koscejev
Copy link
Contributor

@koscejev koscejev commented Dec 2, 2022

Fixes Issue

I noticed checksums can be very slow to calculate for some larger files. One of the reasons is that the file is read 3 times - once per each checksum. (See Dependency.calculateChecksums(File).) This is easy to optimize by reading the file only once and calculating all 3 checksums together.

Description of Change

There are two commits:

  1. calculates (and caches) all supported checksums together for files
  2. (optional) removes dependency on commons-codec since I realized it's barely used and the methods that actually are used are already implemented in this Checksum class

Have test cases been added to cover the new functionality?

No new functionality added, and existing tests already cover the changed functionality.

checksums are frequently calculated together (see Dependency constructor)
so it makes sense to only read files once to calculate all checksums together
use the already existing checksum methods instead
@boring-cyborg boring-cyborg bot added the utils changes to utils label Dec 2, 2022
@jeremylong
Copy link
Owner

CodeQL flagged the use of MD5 - this is not used as a security mechanism.

@jeremylong jeremylong added this to the 7.4.0 milestone Dec 2, 2022
@jeremylong jeremylong merged commit afb09b3 into jeremylong:main Dec 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
utils changes to utils
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants