Skip to content

Commit

Permalink
Extract method to improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
mackdk committed Jul 19, 2023
1 parent 5752a99 commit f01e06f
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -548,13 +548,7 @@ private RepomdIndexData loadRepoMetadataFile(Channel channel, String checksumAlg

try (DigestInputStream digestStream = new DigestInputStream(stream, MessageDigest.getInstance(checksumAlgo))) {

try {
byte[] bytes = new byte[10];
while (digestStream.read(bytes) != -1) {
// no-op, just consume the stream
}
}
catch (IOException e) {
if (!computeDigest(digestStream)) {
return null;
}

Expand All @@ -571,6 +565,19 @@ private RepomdIndexData loadRepoMetadataFile(Channel channel, String checksumAlg
}
}

private static boolean computeDigest(DigestInputStream digestStream) {
try {
byte[] bytes = new byte[10];
while (digestStream.read(bytes) != -1) {
// no-op, just fully consume the stream so that the digest is computed
}
}
catch (IOException e) {
return false;
}
return true;
}

/**
* Generates update info for given channel
* @param channel channel info
Expand Down

0 comments on commit f01e06f

Please sign in to comment.