-
Notifications
You must be signed in to change notification settings - Fork 370
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: refactor createReadStream to remove unnecessary stream #2153
fix: refactor createReadStream to remove unnecessary stream #2153
Conversation
Summary of things change: 1. De-nest all the callbacks in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, denis!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some suggestions, mostly for the hashstream validator
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
Co-authored-by: Daniel Bankhead <[email protected]>
@danielbankhead I accepted most of the suggestions but had to fix up a few things. We cannot deduce whether or not crc32c or md5 checks are enabled purely by the presence of a hash. The server returns these values in the headers and the user may not want the validation so the boolean has to be set from user land. Additionally, |
if (this.updateHashesOnly) { | ||
callback(); | ||
return; | ||
} | ||
|
||
// If we're doing validation, assume the worst-- a data integrity | ||
// mismatch. If not, these tests won't be performed, and we can assume | ||
// the best. | ||
// We must check if the server decompressed the data on serve because hash | ||
// validation is not possible in this case. | ||
let failed = this.crc32cEnabled || this.md5Enabled; | ||
|
||
if (this.crc32cEnabled && this.crc32cExpected) { | ||
failed = !this.test('crc32c', this.crc32cExpected); | ||
} | ||
|
||
if (this.md5Enabled && this.md5Expected) { | ||
failed = !this.test('md5', this.md5Expected); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I see the confusion - I think this block should only be checked in the presence of this.crc32cExpected
or this.md5Expected
(otherwise, if either aren't available then this would always fail).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, the _flush
suggestion is optional
Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:
Fixes #<issue_number_goes_here> 🦕