From c52ca29600ea5c73d7c0e5257c158c08005b0c8b Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Mon, 2 Oct 2023 11:58:20 +0530 Subject: lib/curl: preserve nil value of hcode hcode is nil because curl was't able to fulfill the http request, either because curl package is broken or mpv killed it prematurely. we can exit out of retry loop early if hcode is nil since there's no point in retrying --- lib/curl.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/curl.lua b/lib/curl.lua index db501db..c8ae478 100644 --- a/lib/curl.lua +++ b/lib/curl.lua @@ -36,7 +36,10 @@ local get = function (url, headr, args) args = util.array_merge(args, head_to_args(headr)) fetch = util.run(args) - hcode = fetch:match('%d*$') or 000 + -- hcode can be nil, it means curl was't able to fulfill the http request, either + -- because curl package is broken or mpv killed it prematurely. we can exit + -- out of retry loop early if hcode is nil since there's no point in retrying + hcode = fetch:match('%d*$') fetch = fetch:gsub('%s*%d*$', '') return fetch, tonumber(hcode) -- cgit v1.2.3