'Fixed' downloads failing at point due to Excon shared connection and threads, added byte size formatter

This commit is contained in:
2021-11-16 11:31:47 -06:00
parent db97b5a3ab
commit dab16e7663
3 changed files with 24 additions and 3 deletions

View File

@@ -51,11 +51,12 @@ class W3DHub
file.write(chunk)
block.call(chunk, remaining_bytes, total_bytes)
# puts "Remaining: #{remaining_bytes.to_f / total_bytes}%"
puts " Remaining: #{((remaining_bytes.to_f / total_bytes) * 100.0).round}% (#{W3DHub::format_size(total_bytes - remaining_bytes)} / #{W3DHub::format_size(total_bytes)})"
end
response = socket.post(
path: "apis/launcher/1/get-package",
# Create a new connection due to some weirdness somewhere in Excon
response = Excon.post(
"#{Api::ENDPOINT}/apis/launcher/1/get-package",
headers: Api::DEFAULT_HEADERS.merge({"Content-Type": "application/x-www-form-urlencoded"}),
body: "data=#{JSON.dump({ category: category, subcategory: subcategory, name: name, version: version })}",
response_block: streamer