diff --git a/src/gmt_remote.c b/src/gmt_remote.c index 3d26ec47357..af1d24ac28d 100644 --- a/src/gmt_remote.c +++ b/src/gmt_remote.c @@ -1110,6 +1110,7 @@ int gmtlib_file_is_jpeg2000_tile (struct GMTAPI_CTRL *API, char *file) { } int gmt_download_file (struct GMT_CTRL *GMT, const char *name, char *url, char *localfile, bool be_fussy) { + bool query = gmt_M_file_is_query (url); int curl_err, error; size_t fsize; char *Lfile = NULL; @@ -1135,12 +1136,14 @@ int gmt_download_file (struct GMT_CTRL *GMT, const char *name, char *url, char * /* Here we will try to download a file */ - Lfile = gmtremote_lockfile (API, (char *)name); - if ((fp = fopen (Lfile, "w")) == NULL) { - GMT_Report (API, GMT_MSG_ERROR, "Failed to create lock file %s\n", Lfile); - return 1; + if (!query) { /* Only make a filename if not a query */ + Lfile = gmtremote_lockfile (API, (char *)name); + if ((fp = fopen (Lfile, "w")) == NULL) { + GMT_Report (API, GMT_MSG_ERROR, "Failed to create lock file %s\n", Lfile); + return 1; + } + gmtlib_file_lock (GMT, fileno(fp)); /* Attempt exclusive lock */ } - gmtlib_file_lock (GMT, fileno(fp)); /* Attempt exclusive lock */ if ((Curl = curl_easy_init ()) == NULL) { GMT_Report (API, GMT_MSG_ERROR, "Failed to initiate curl\n"); @@ -1196,9 +1199,11 @@ int gmt_download_file (struct GMT_CTRL *GMT, const char *name, char *url, char * if (urlfile.fp) /* close the local file */ fclose (urlfile.fp); - gmtlib_file_unlock (GMT, fileno(fp)); - gmt_remove_file (GMT, Lfile); - gmt_M_str_free (Lfile); + if (!query) { /* Remove lock file after successful download */ + gmtlib_file_unlock (GMT, fileno(fp)); + gmt_remove_file (GMT, Lfile); + gmt_M_str_free (Lfile); + } gmtremote_turn_off_ctrl_C_check ();