@@ -3,6 +3,7 @@ module VersionsJSONUtil
33# #### --------------------------------------------------------------------------------------
44# #### Import dependencies
55
6+ using Downloads: Downloads
67using EnumX: EnumX, @enumx
78using GitHub: GitHub
89using HTTP: HTTP
@@ -26,7 +27,7 @@ include("sha_structs.jl")
2627
2728include (" typed_json.jl" )
2829
29- include (" download .jl" )
30+ include (" web_cache_utilities .jl" )
3031
3132# #### --------------------------------------------------------------------------------------
3233# #### Config, OutputJsonContent
@@ -331,16 +332,18 @@ function filedict_is_complete_and_good(filedict::FileDict)
331332
332333 # Now the (compared to the rest of this function) expensive part: Check our Etag.
333334 url = filedict. url
334- old_headinfo = HeadInfo (;
335- etag = filedict. etag,
336- last_modified = filedict. last_modified,
337- )
335+ old_etag = filedict. etag
336+ old_last_modified = filedict. last_modified
338337 new_headinfo = get_new_headinfo_for_url (url)
339338 if isnothing (new_headinfo)
340339 return false
341340 end
342- if old_headinfo != new_headinfo
343- @warn " HeadInfo for URL $url has changed from $old_headinfo to $new_headinfo "
341+ if old_etag != new_headinfo. etag
342+ @warn " ETag for URL $url has changed from $(old_etag) to $(new_headinfo. etag) "
343+ return false
344+ end
345+ if old_last_modified != new_headinfo. last_modified
346+ @warn " Last-Modified for URL $url has changed from $(old_last_modified) to $(new_headinfo. last_modified) "
344347 return false
345348 end
346349
@@ -433,9 +436,13 @@ function get_tags()
433436 else
434437 # The user didn't provide GITHUB_TOKEN, so we have to make an unauthenticated call
435438 # to the GitHub API.
436- # Warning: The rate limit for unauthenticated calls is very low.
439+ # The rate limit for unauthenticated calls is very low, so we cache this .
437440 @warn " GITHUB_TOKEN not detected. It is recommended that you provide a GITHUB_TOKEN (with read-only access to only public repos)."
438- return GitHub. gh_get_json (GitHub. DEFAULT_API, " /$request_path " ; auth)
441+ tags_json_path = download_to_cache (
442+ " julia_tags.json" ,
443+ " https://api.github.com/$request_path " ,
444+ )
445+ return JSON. parse (String (read (tags_json_path)))
439446 end
440447end
441448
@@ -540,7 +547,7 @@ function main!(content::OutputJsonContent, cfg::Config)
540547
541548 # Download this URL to a local file in a temp directory
542549 number_urls_tried += 1
543- filepath = Downloads. download (url)
550+ filepath = Downloads. download (string ( url) )
544551
545552 if filesize (filepath) == 0
546553 # The file is empty
@@ -572,7 +579,7 @@ function main!(content::OutputJsonContent, cfg::Config)
572579 kind = " archive"
573580 extension = " zip"
574581 else
575- error (" Unsupported file extension in filename: $( filename) " )
582+ error (" Unsupported file extension in filename: filename" )
576583 end
577584
578585 if extension == " tar.gz" && ! (url in tarball_git_tree_hash_skiplist)
0 commit comments