Skip to content

Commit

Permalink
Replace deprecated CURLINFO_CONTENT_LENGTH_DOWNLOAD (#8659)
Browse files Browse the repository at this point in the history
* Replace deprecated CURLINFO_CONTENT_LENGTH_DOWNLOAD

* Force CURL > 7.55.0
  • Loading branch information
remkos authored Jan 3, 2025
1 parent 79800bd commit 7aed048
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ message (STATUS "Searching dependent libraries. This may take a few minutes...")
find_package (NETCDF REQUIRED)
include_directories (${NETCDF_INCLUDE_DIR})

# libcurl is required since 5.4
find_package (CURL REQUIRED)
# libcurl is required since GMT 5.4
# At least version 7.55.0 is needed for src/gmt_remote.c
find_package (CURL 7.55.0 REQUIRED)
include_directories (${CURL_INCLUDE_DIRS})
list (APPEND GMT_OPTIONAL_LIBRARIES ${CURL_LIBRARIES})
set (CURL_LIBRARY ${CURL_LIBRARIES} CACHE INTERNAL "")
Expand Down
6 changes: 3 additions & 3 deletions src/gmt_remote.c
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ GMT_LOCAL size_t gmtremote_skip_large_files (struct GMT_CTRL *GMT, char * URL, s
/* Get the remote file's size and if too large we refuse to download */
CURL *curl = NULL;
CURLcode res;
double filesize = 0.0;
curl_off_t filesize = 0;
size_t action = 0;
char curl_useragent[GMT_LEN64];

Expand Down Expand Up @@ -677,10 +677,10 @@ GMT_LOCAL size_t gmtremote_skip_large_files (struct GMT_CTRL *GMT, char * URL, s
res = curl_easy_perform (curl);

if ((res = curl_easy_perform (curl)) == CURLE_OK) {
res = curl_easy_getinfo (curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize);
res = curl_easy_getinfo (curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &filesize);
if ((res == CURLE_OK) && (filesize > 0.0)) { /* Got the size */
GMT_Report (GMT->parent, GMT_MSG_INFORMATION, "Remote file %s: Size is %0.0f bytes\n", URL, filesize);
action = (filesize < (double)limit) ? 0 : (size_t)filesize;
action = ((size_t)filesize < limit) ? 0 : (size_t)filesize;
}
}
else /* We failed */
Expand Down

0 comments on commit 7aed048

Please sign in to comment.