@@ -4,6 +4,7 @@ using HTTP, JSON, Pkg.BinaryPlatforms, WebCacheUtilities, SHA, Lazy
44using Tar: Tar
55import Pkg. BinaryPlatforms: triplet, arch
66import Pkg. PlatformEngines: exe7z
7+ using URIs: URIs, URI
78
89" Wrapper types to define three jlext methods for portable, tarball and installer Windows"
910struct WindowsPortable
@@ -143,6 +144,31 @@ function get_tags()
143144 JSON. parse (String (read (tags_json_path)))
144145end
145146
147+ # #### --------------------------------------------------------------------------------------
148+ # #### Get ETag and Last-Modified, so we know if we need to re-download and re-checksum files
149+
150+ Base. @kwdef struct HeadInfo
151+ url:: URI
152+ etag:: Union{String, Nothing}
153+ last_modified:: Union{String, Nothing}
154+ end
155+
156+ function HeadInfo (url)
157+ local response = nothing
158+ try
159+ response = HTTP. head (url)
160+ catch
161+ error (" Encountered error when making HEAD request to URL: $url " )
162+ end
163+ etag = HTTP. header (response, " ETag" , nothing )
164+ etag === nothing && @warn " ETag not provided in response from $url "
165+ last_modified = HTTP. header (response, " Last-Modified" , nothing )
166+ last_modified === nothing && @warn " Last-Modified not provided in response from $url "
167+ return HeadInfo (; url= URI (url), etag, last_modified)
168+ end
169+
170+ # #### --------------------------------------------------------------------------------------
171+
146172function main (out_path)
147173 tags = get_tags ()
148174 tag_versions = filter (x -> x != = nothing , [vnum_maybe (basename (t[" ref" ])) for t in tags])
@@ -240,6 +266,8 @@ function main(out_path)
240266
241267 end
242268
269+ headinfo = HeadInfo (url)
270+
243271 # Build up metadata about this file
244272 file_dict = Dict (
245273 " triplet" => triplet (platform),
@@ -260,6 +288,13 @@ function main(out_path)
260288 file_dict[" asc" ] = asc_signature
261289 end
262290
291+ if ! isnothing (headinfo. etag)
292+ file_dict[" etag" ] = headinfo. etag
293+ end
294+ if ! isnothing (headinfo. last_modified)
295+ file_dict[" last-modified" ] = headinfo. last_modified
296+ end
297+
263298 # Right now, all we have are archives, but let's be forward-thinking
264299 # and make this an array of dictionaries that is easy to extensibly match
265300 push! (meta[version][" files" ], file_dict)
0 commit comments