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

Pivotal # 177647985: MD5 Calculation For Big Files #366

Merged
merged 2 commits into from
Apr 12, 2021

Conversation

jhoanmanuelms
Copy link
Contributor

https://www.pivotaltracker.com/story/show/177647985

Switch from full read file for MD5 calculation to a buffered reader approach

Switch from full read file for MD5 calculation to a buffered reader approach
@jhoanmanuelms jhoanmanuelms self-assigned this Apr 7, 2021
@jhoanmanuelms jhoanmanuelms requested a review from Juan-EBI April 7, 2021 13:50

val md5sum = BigInteger(CHECKSUM_SIGNUM, digest.digest()).toString(HEXADECIMAL_BASE)
return String.format("%32s", md5sum).replace(" ", "0")
}
Copy link
Contributor

@Juan-EBI Juan-EBI Apr 10, 2021

Choose a reason for hiding this comment

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

fun md5(file: File): String {
    val digest = MessageDigest.getInstance(MD5_ALGORITHM)
    file.inputStream().buffered(BUFFER_SIZE).use { it.iterator().forEach(digest::update) }
    return digest.digest().joinToString("") { "%02x".format(it) }
}

Maybe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Works like a charm! I knew there was a better way to write this. Nice comment 😁👍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

@jhoanmanuelms jhoanmanuelms merged commit 3f3fd98 into master Apr 12, 2021
@jhoanmanuelms jhoanmanuelms deleted the bugfix/pivotal-177647985-md5-big-files branch April 12, 2021 14:24
jhoanmanuelms added a commit that referenced this pull request Apr 15, 2021
Feature:
* Pivotal ID # 177304040: PT Submit Migration Operation (#362)

Bugfix:
* Pivotal ID # 177536825: Add handler for SubmissionNotFoundException to response with the correct http status code (#364)
* Pivotal # 177647985: MD5 Calculation For Big Files (#366)
* Pivotal ID #177756846: Allow to bypass toxic risk validation when QMRF-ID attribute (#370)

Chore:
* Pivotal ID #177423348: PMC integration test (#356)
* Pivotal ID # 177413307: Report Submissions With Errors (#368)

Co-authored-by: Juan <jcamilorada@ebi.ac.uk>
Co-authored-by: Néstor Diaz <ndiaz@ebi.ac.uk>
jhoanmanuelms added a commit that referenced this pull request Apr 16, 2021
Feature:
* Pivotal ID # 177304040: PT Submit Migration Operation (#362)

Bugfix:
* Pivotal ID # 177536825: Add handler for SubmissionNotFoundException to response with the correct http status code (#364)
* Pivotal # 177647985: MD5 Calculation For Big Files (#366)
* Pivotal ID #177756846: Allow to bypass toxic risk validation when QMRF-ID attribute (#370)

Chore:
* Pivotal ID #177423348: PMC integration test (#356)
* Pivotal ID # 177413307: Report Submissions With Errors (#368)

Co-authored-by: Juan <jcamilorada@ebi.ac.uk>
Co-authored-by: Néstor Diaz <ndiaz@ebi.ac.uk>
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