@@ -143,6 +143,38 @@ function get_tags()
143143 JSON. parse (String (read (tags_json_path)))
144144end
145145
146+ # #### --------------------------------------------------------------------------------------
147+ # #### Get ETag and Last-Modified, so we know if we need to re-download and re-checksum files
148+
149+ Base. @kwdef struct HeadInfo
150+ etag:: Union{String, Nothing}
151+ last_modified:: Union{String, Nothing}
152+ end
153+
154+ function get_new_headinfo_for_url (url:: URI )
155+ local response = nothing
156+ try
157+ response = HTTP. head (url)
158+ catch
159+ error (" Encountered error when making HEAD request to URL: $url " )
160+ end
161+ headers = Dict (HTTP. headers (response))
162+ etag = get (headers, " ETag" , " " )
163+ last_modified = get (headers, " Last-Modified" , " " )
164+ if isempty (strip (etag))
165+ @warn " Got empty new ETag for URL: $new_etag "
166+ etag = nothing
167+ end
168+ if isempty (strip (last_modified))
169+ @warn " Got empty new ETag for URL: $new_etag "
170+ last_modified = nothing
171+ end
172+ head_info = HeadInfo (; etag, last_modified)
173+ return head_info
174+ end
175+
176+ # #### --------------------------------------------------------------------------------------
177+
146178function main (out_path)
147179 tags = get_tags ()
148180 tag_versions = filter (x -> x != = nothing , [vnum_maybe (basename (t[" ref" ])) for t in tags])
@@ -240,6 +272,8 @@ function main(out_path)
240272
241273 end
242274
275+ headinfo = get_new_headinfo_for_url (url)
276+
243277 # Build up metadata about this file
244278 file_dict = Dict (
245279 " triplet" => triplet (platform),
@@ -260,6 +294,13 @@ function main(out_path)
260294 file_dict[" asc" ] = asc_signature
261295 end
262296
297+ if ! isnothing (headinfo. etag)
298+ file_dict[" etag" ] = headinfo. etag
299+ end
300+ if ! isnothing (headinfo. last_modified)
301+ file_dict[" last-modified" ] = headinfo. last_modified
302+ end
303+
263304 # Right now, all we have are archives, but let's be forward-thinking
264305 # and make this an array of dictionaries that is easy to extensibly match
265306 push! (meta[version][" files" ], file_dict)
0 commit comments