You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
GMT should not download the gmt_data_server.txt file if no remote files are used #3609
Every gmt command checks if gmt_data_server.txt and gmt_hash_server.txt exist locally. If not, GMT will download these two files from the GMT data server. GMT command also checks if these two files are older than 24 hours and try to refresh them if they are. It works well for users with good internet connections and users without internet connections.
However, it's a terrible experience for users who have very slow internet connections or work with intranet (intranet has network connections but can't visit external websites). Every time they run a gmt command, they need to wait for the timeout of the GMT server (~30 s). They won't understand why GMT is so slow, since the timeout message is not shown unless -Vi is used. Even -Vi is used, they may still be confused why GMT tries to download the two files even though they don't use any remote files like @earth_relief_01d.
IMHO, it's not a good design to let gmt check and download the two files every time. A better behavior is only try to download the two files if remote files are needed.
Right now we call gmtlib_refresh_server during the start of every session (so for most uses, this means every time a module is run, regardless of what the module actually does or if remote files are even requested). I think this might work well:
Move that call to the top of gmt_download_file_if_not_found. That is the function that determines if a requested file will need to be downloaded so we could do a just-in-time call to gmtlib_refresh_server. There may be several calls to gmt_download_file_if_not_found in that one session but it does not matter since once we do it once we set a bool flag so the function returns immediately if called again.
We would also need to call it explicitly when running gmtget-D.
As I understand it, gmt_download_file_if_not_found function also deals with other URLs (not GMT remote files). Ideally, GMT should call gmtlib_refresh_server only if a remote file @xxx is requested, but I'm OK with what you proposed if it's easier to implement, since downloading any files (GMT remote files or other URLs) needs good internet connections.
I'm not sure if my understanding of gmt_download_file_if_not_found is correct. If a file already exists locally, this function will do nothing, right? Does it mean that if I already have earth_relief_01d_p.grd locally, it will never refresh the server files, so the local earth_relief_01d_p.grd won't be updated?
As for point 1, we can do the refresh if the file starts with @ only. As for 2: The server file refresh is strictly a 24-hour clock thing. It does not care if you have a particular file or not since, as you point out, it may be obsolete. So we always refresh the server listing if > 24 hours old. This is of course separate from me still needing to implement a data tile/set refresh if older than the date in the listing....
One more thing, can we add one more parameter (i.e., GMT_DATA_SERVER_FREQUENCY) so that users can control the frequency of the refreshing (24-hour by default). The reason is that some users may want to use the remote files but don't care about if the data are the latest or not.
Sorry, taking abit longer that envision since quickly learning that the only place it needs to go is in gmt_init_module where we loop over the arguments and check if any start with @. We then do some registration check. Here is where we call the refresh, once. I can imaging we may have an arg like -Bxc@somefile so perhaps to be super-careful we should call refresh if any argument contains the letter @? At this point, we do not know what any argument means, so even though we may trigger on -B+t" My email is bob@devnull" it does not cause much damage?
If we dont do that here then we would need to also check in many other places. if refresh is not called then the dataset array is NULL and we may crash and burn.
Activity
PaulWessel commentedon Jul 6, 2020
Agreed. I will see where to implement a just-in-time solution.
PaulWessel commentedon Jul 6, 2020
Right now we call gmtlib_refresh_server during the start of every session (so for most uses, this means every time a module is run, regardless of what the module actually does or if remote files are even requested). I think this might work well:
Think this will cover all bases, @seisman?
seisman commentedon Jul 6, 2020
As I understand it, gmt_download_file_if_not_found function also deals with other URLs (not GMT remote files). Ideally, GMT should call gmtlib_refresh_server only if a remote file
@xxxis requested, but I'm OK with what you proposed if it's easier to implement, since downloading any files (GMT remote files or other URLs) needs good internet connections.I'm not sure if my understanding of gmt_download_file_if_not_found is correct. If a file already exists locally, this function will do nothing, right? Does it mean that if I already have earth_relief_01d_p.grd locally, it will never refresh the server files, so the local earth_relief_01d_p.grd won't be updated?
PaulWessel commentedon Jul 6, 2020
As for point 1, we can do the refresh if the file starts with @ only. As for 2: The server file refresh is strictly a 24-hour clock thing. It does not care if you have a particular file or not since, as you point out, it may be obsolete. So we always refresh the server listing if > 24 hours old. This is of course separate from me still needing to implement a data tile/set refresh if older than the date in the listing....
seisman commentedon Jul 6, 2020
Then it sounds good to me.
One more thing, can we add one more parameter (i.e., GMT_DATA_SERVER_FREQUENCY) so that users can control the frequency of the refreshing (24-hour by default). The reason is that some users may want to use the remote files but don't care about if the data are the latest or not.
PaulWessel commentedon Jul 6, 2020
Sure, that is a good idea, but perhaps a new 6.2 feature? Make an issue.
PaulWessel commentedon Jul 6, 2020
Sorry, taking abit longer that envision since quickly learning that the only place it needs to go is in gmt_init_module where we loop over the arguments and check if any start with @. We then do some registration check. Here is where we call the refresh, once. I can imaging we may have an arg like -Bxc@somefile so perhaps to be super-careful we should call refresh if any argument contains the letter @? At this point, we do not know what any argument means, so even though we may trigger on -B+t" My email is bob@devnull" it does not cause much damage?
PaulWessel commentedon Jul 6, 2020
If we dont do that here then we would need to also check in many other places. if refresh is not called then the dataset array is NULL and we may crash and burn.
seisman commentedon Jul 8, 2020
Implemented in #3616