mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
file(DOWNLOAD): Don't fail if given just a filename to write to
Fixes: #17969
This commit is contained in:
@@ -1707,7 +1707,8 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
|
||||
// as we receive downloaded bits from curl...
|
||||
//
|
||||
std::string dir = cmSystemTools::GetFilenamePath(file);
|
||||
if (!cmSystemTools::FileExists(dir) && !cmSystemTools::MakeDirectory(dir)) {
|
||||
if (!dir.empty() && !cmSystemTools::FileExists(dir) &&
|
||||
!cmSystemTools::MakeDirectory(dir)) {
|
||||
std::string errstring = "DOWNLOAD error: cannot create directory '" + dir +
|
||||
"' - Specify file by full path name and verify that you "
|
||||
"have directory creation and file write privileges.";
|
||||
|
||||
@@ -145,3 +145,21 @@ file(DOWNLOAD
|
||||
)
|
||||
message(STATUS "${status}")
|
||||
__reportIfWrongStatus("${status}" 6) # 6 corresponds to an unresolvable host name
|
||||
|
||||
message(STATUS "FileDownload:12")
|
||||
set(absFile "@CMAKE_CURRENT_BINARY_DIR@/file12.png")
|
||||
if(EXISTS "${absFile}")
|
||||
file(RENAME ${absFile} "${absFile}_beingRemoved")
|
||||
file(REMOVE "${absFile}_beingRemoved")
|
||||
endif()
|
||||
file(DOWNLOAD
|
||||
${url}
|
||||
file12.png
|
||||
TIMEOUT ${timeout}
|
||||
EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92
|
||||
STATUS status
|
||||
)
|
||||
__reportIfWrongStatus("${status}" 0)
|
||||
if(NOT EXISTS file12.png)
|
||||
message(SEND_ERROR "file12.png not downloaded: ${status}")
|
||||
endif()
|
||||
|
||||
@@ -183,7 +183,7 @@ elseif(testname STREQUAL to_native_path) # pass
|
||||
elseif(testname STREQUAL download_wrong_number_of_args) # fail
|
||||
file(DOWNLOAD zzzz://bogus/ffff)
|
||||
|
||||
elseif(testname STREQUAL download_file_with_no_path) # fail
|
||||
elseif(testname STREQUAL download_file_with_no_path) # pass
|
||||
file(DOWNLOAD zzzz://bogus/ffff ffff)
|
||||
|
||||
elseif(testname STREQUAL download_missing_time) # fail
|
||||
|
||||
Reference in New Issue
Block a user