-
Notifications
You must be signed in to change notification settings - Fork 3
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
Closes #61 Check MD5 regardless of quiet flag value #62
Conversation
@enriquemondragon great job on deduplication! Two points:
x <- java_download(8, quiet = FALSE, force = FALSE)
# or
x <- java_download(8, quiet = FALSE, force = TRUE)
# or any other combination of arguments And the file does not yet exist, the function will not download the file and no md5 check will be performed.
I would argue that it is actually best to throw an error and stop, rather than just a warning, as broken distribution file will lead to problems during install and use of Java, so it's best to fail. |
@e-kotov thank you! I explicitly wrote down all the if cases and created a function called Edit: I just saw that one test failed, I'll check this |
yep, it's because of the # Download distribution and check MD5 checksum
download_dist_check_md5 <- function(url, dest_file, md5sum, md5sum_expectedm, quiet) {
curl::curl_download(url, dest_file, quiet = FALSE)
curl::curl_download(url_md5, dest_file_md5, quiet = TRUE)
if (!quiet) {
cli::cli_inform("Download completed.", .envir = environment())
}
md5sum <- tools::md5sum(dest_file)
md5sum_expected <- readLines(dest_file_md5, warn = FALSE)
if (md5sum != md5sum_expected) {
cli::cli_alert_danger("MD5 checksum mismatch. Please try downloading the file again.", .envir = environment())
unlink(dest_file)
return(NULL)
} else {
if (!quiet) {
cli::cli_inform("MD5 checksum verified.", .envir = environment())
}
}
} perhaps you don't need these args at all as you overwrite them anyway in lines: md5sum <- tools::md5sum(dest_file)
md5sum_expected <- readLines(dest_file_md5, warn = FALSE) |
Thank you, I think this has been corrected. I also removed the redundant args |
md5sum_expected <- readLines(dest_file_md5, warn = FALSE) | ||
|
||
if (md5sum != md5sum_expected) { | ||
cli::cli_abort("MD5 checksum mismatch. Please try downloading the file again.", .envir = environment()) |
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.
@enriquemondragon I replaced the warning with cli_abort, so that the functions stops in case of MD5 check fail. Otherwise, the user may miss the error and unknowingly continue with the corrupted distribution.
@enriquemondragon all done now! Great, thanks for your input! |
Closes #61 Check MD5 regardless of quiet flag value