@@ -132,6 +132,38 @@ function get_tags()
132132 JSON. parse (String (read (tags_json_path)))
133133end
134134
135+ # #### --------------------------------------------------------------------------------------
136+ # #### Get ETag and Last-Modified, so we know if we need to re-download and re-checksum files
137+
138+ Base. @kwdef struct HeadInfo
139+ etag:: Union{String, Nothing}
140+ last_modified:: Union{String, Nothing}
141+ end
142+
143+ function get_new_headinfo_for_url (url:: URI )
144+ local response = nothing
145+ try
146+ response = HTTP. head (url)
147+ catch
148+ error (" Encountered error when making HEAD request to URL: $url " )
149+ end
150+ headers = Dict (HTTP. headers (response))
151+ etag = get (headers, " ETag" , " " )
152+ last_modified = get (headers, " Last-Modified" , " " )
153+ if isempty (strip (etag))
154+ @warn " Got empty new ETag for URL: $new_etag "
155+ etag = nothing
156+ end
157+ if isempty (strip (last_modified))
158+ @warn " Got empty new ETag for URL: $new_etag "
159+ last_modified = nothing
160+ end
161+ head_info = HeadInfo (; etag, last_modified)
162+ return head_info
163+ end
164+
165+ # #### --------------------------------------------------------------------------------------
166+
135167function main (out_path)
136168 tags = get_tags ()
137169 tag_versions = filter (x -> x != = nothing , [vnum_maybe (basename (t[" ref" ])) for t in tags])
@@ -211,6 +243,9 @@ function main(out_path)
211243 else
212244 error (" Unsupported file extension in filename: $(filename) " )
213245 end
246+
247+ headinfo = get_new_headinfo_for_url (url)
248+
214249 file_dict = Dict (
215250 " triplet" => triplet (platform),
216251 " os" => meta_os (platform),
@@ -227,6 +262,13 @@ function main(out_path)
227262 file_dict[" asc" ] = asc_signature
228263 end
229264
265+ if ! isnothing (headinfo. etag)
266+ file_dict[" etag" ] = headinfo. etag
267+ end
268+ if ! isnothing (headinfo. last_modified)
269+ file_dict[" last-modified" ] = headinfo. last_modified
270+ end
271+
230272 # Right now, all we have are archives, but let's be forward-thinking
231273 # and make this an array of dictionaries that is easy to extensibly match
232274 push! (meta[version][" files" ], file_dict)
0 commit comments