@@ -520,6 +520,7 @@ GMT_LOCAL size_t gmtremote_skip_large_files (struct GMT_CTRL *GMT, char * URL, s
520520#define GMT_HASH_TIME_OUT 10L /* Not waiting longer than this to time out on getting the hash file */
521521
522522GMT_LOCAL int gmtremote_get_url (struct GMT_CTRL * GMT , char * url , char * file , char * orig , unsigned int index ) {
523+ bool query = gmt_M_file_is_query (file );
523524 int curl_err = 0 ;
524525 long time_spent ;
525526 char * Lfile = NULL ;
@@ -529,12 +530,14 @@ GMT_LOCAL int gmtremote_get_url (struct GMT_CTRL *GMT, char *url, char *file, ch
529530 struct GMTAPI_CTRL * API = GMT -> parent ;
530531 time_t begin , end ;
531532
532- Lfile = gmtremote_lockfile (API , file );
533- if ((fp = fopen (Lfile , "w" )) == NULL ) {
534- GMT_Report (API , GMT_MSG_ERROR , "Failed to create lock file %s\n" , Lfile );
535- return 1 ;
533+ if (!query ) { /* Only make a filename if not a query */
534+ Lfile = gmtremote_lockfile (API , file );
535+ if ((fp = fopen (Lfile , "w" )) == NULL ) {
536+ GMT_Report (API , GMT_MSG_ERROR , "Failed to create lock file %s\n" , Lfile );
537+ return 1 ;
538+ }
539+ gmtlib_file_lock (GMT , fileno (fp )); /* Attempt exclusive lock */
536540 }
537- gmtlib_file_lock (GMT , fileno (fp )); /* Attempt exclusive lock */
538541
539542 if ((Curl = curl_easy_init ()) == NULL ) {
540543 GMT_Report (GMT -> parent , GMT_MSG_ERROR , "Failed to initiate curl - cannot obtain %s\n" , url );
@@ -600,9 +603,12 @@ GMT_LOCAL int gmtremote_get_url (struct GMT_CTRL *GMT, char *url, char *file, ch
600603 curl_easy_cleanup (Curl );
601604 if (urlfile .fp ) /* close the local file */
602605 fclose (urlfile .fp );
603- gmtlib_file_unlock (GMT , fileno (fp ));
604- gmt_remove_file (GMT , Lfile );
605- gmt_M_str_free (Lfile );
606+
607+ if (!query ) { /* Remove lock file after successful download */
608+ gmtlib_file_unlock (GMT , fileno (fp ));
609+ gmt_remove_file (GMT , Lfile );
610+ gmt_M_str_free (Lfile );
611+ }
606612
607613 gmtremote_turn_off_ctrl_C_check ();
608614 return 0 ;
0 commit comments