diff --git a/utils/buildactions/install_cef.lua b/utils/buildactions/install_cef.lua index 0b45e8ac7ed..1facf1bc616 100644 --- a/utils/buildactions/install_cef.lua +++ b/utils/buildactions/install_cef.lua @@ -111,7 +111,7 @@ newaction { else -- Download CEF print("Downloading CEF " .. CEF_VERSION .. "...") - if not http.download_print_errors(make_cef_download_url(), archive_path) then + if not http.download_print_errors(make_cef_download_url(), archive_path, { progress = http.create_download_progress_handler{update_interval_s = 5} }) then os.exit(1) return end diff --git a/utils/buildactions/utils.lua b/utils/buildactions/utils.lua index 42899f4769b..2268d8c7d77 100644 --- a/utils/buildactions/utils.lua +++ b/utils/buildactions/utils.lua @@ -129,6 +129,24 @@ function os.extract_archive(archive_path, target_path, override) return false end +function http.create_download_progress_handler(options) + local last_update = 0 + + return function (total, current) + local tick = os.clock() + if tick - last_update < options.update_interval_s then + return + end + + last_update = tick + + local ratio = current / total; + ratio = math.min(math.max(ratio, 0), 1) + local percent = math.floor(ratio * 100) + print(string.format("Downloading (%d/%d) %d%%", current, total, percent)) + end +end + function http.download_print_errors(url, file, options) local result_str, response_code = http.download(url, file, options) if result_str ~= "OK" then