diff options
| author | sinanmohd <sinan@sinanmohd.com> | 2023-10-01 20:00:12 +0530 | 
|---|---|---|
| committer | sinanmohd <sinan@sinanmohd.com> | 2023-10-01 20:00:12 +0530 | 
| commit | 994715046cedee5b9ab4f61a4112a2c73d506960 (patch) | |
| tree | 59d955219f3e28bb8287bc1b024a3bffe89f138e /lib | |
| parent | fee405edd055656dd63690e03a0d3e1fc0e96b4e (diff) | |
curl: sub_fetch -> curl.zip_to_local_file
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/curl.lua | 20 | 
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/curl.lua b/lib/curl.lua index 0728def..a832461 100644 --- a/lib/curl.lua +++ b/lib/curl.lua @@ -34,6 +34,26 @@ local get = function (url, headr, args)  	return fetch, tonumber(scode)  end +local zip_to_local_file = function (url, headr, out, retries) +	local tries, hcode, zip, zcode + +	tries = 0 +	zip = os.tmpname() + +	repeat +		_, hcode = get(url, headr, '-o ' .. zip) +		tries = tries + 1 +	until hcode == 200 or tries > retries + +	if hcode == 200 then +		zcode = util.zip_ext_first(zip, out) +	end +	os.remove(zip) + +	return (hcode == 200) and zcode +end +  return {  	get = get, +	zip_to_local_file = zip_to_local_file,  }  | 
