download_file(): avoid copying files if the correct file already exists

develop
lethosor 2017-03-18 00:31:15 -04:00
parent 38702febf7
commit 50a022d81b
1 changed files with 9 additions and 9 deletions

@ -25,6 +25,7 @@ function(download_file URL DEST EXPECTED_MD5)
get_filename_component(FILENAME "${URL}" NAME) get_filename_component(FILENAME "${URL}" NAME)
file_md5_if_exists("${DEST}" CUR_MD5) file_md5_if_exists("${DEST}" CUR_MD5)
if(NOT "${EXPECTED_MD5}" STREQUAL "${CUR_MD5}")
search_downloads(${EXPECTED_MD5} DLPATH) search_downloads(${EXPECTED_MD5} DLPATH)
if(NOT("${DLPATH}" STREQUAL "")) if(NOT("${DLPATH}" STREQUAL ""))
message("* Copying ${FILENAME} from ${DLPATH}") message("* Copying ${FILENAME} from ${DLPATH}")
@ -34,7 +35,6 @@ function(download_file URL DEST EXPECTED_MD5)
return() return()
endif() endif()
if(NOT "${EXPECTED_MD5}" STREQUAL "${CUR_MD5}")
message("* Downloading ${FILENAME}") message("* Downloading ${FILENAME}")
file(DOWNLOAD "${URL}" "${DEST}" EXPECTED_MD5 "${EXPECTED_MD5}" SHOW_PROGRESS) file(DOWNLOAD "${URL}" "${DEST}" EXPECTED_MD5 "${EXPECTED_MD5}" SHOW_PROGRESS)
endif() endif()