mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-11-05 09:34:13 +00:00
Support downloading packages from upstream
This commit is contained in:
@@ -288,8 +288,19 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# TODO xD
|
@worker.w3dhub_api.fetch_package(pkg, path: file_path, range: partially_valid_at) do |downloaded_bytes, total_downloaded_bytes, content_length|
|
||||||
@worker.w3dhub_api.fetch_package("TODO")
|
sample_downloaded_bytes += downloaded_bytes
|
||||||
|
total_data_downloaded_bytes += downloaded_bytes
|
||||||
|
|
||||||
|
if Gosu.milliseconds - last_sample_time_ms >= 1_000
|
||||||
|
last_sample_time_ms = Gosu.milliseconds
|
||||||
|
|
||||||
|
fraction = (total_downloaded_bytes + partially_valid_at) / pkg.file_size.to_f
|
||||||
|
|
||||||
|
update_stage_progress(label: "Downloading #{W3DHubLauncher.format_size(total_data_downloaded_bytes)} / #{W3DHubLauncher.format_size(total_data_to_download_bytes)} [#{W3DHubLauncher.format_size(sample_downloaded_bytes)}/s]", fraction: (i.to_f + fraction) / manifest_packages.size)
|
||||||
|
sample_downloaded_bytes = 0
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
abort_task!("Failed to download required package: #{pkg.name}:#{pkg.version} (#{result.error})") unless result.okay?
|
abort_task!("Failed to download required package: #{pkg.name}:#{pkg.version} (#{result.error})") unless result.okay?
|
||||||
@@ -530,8 +541,7 @@ module W3DHubLauncher
|
|||||||
result = if manifest_package.download_url
|
result = if manifest_package.download_url
|
||||||
@worker.w3dhub_api.download(manifest_package.download_url, path: file_path)
|
@worker.w3dhub_api.download(manifest_package.download_url, path: file_path)
|
||||||
else
|
else
|
||||||
# TODO xD
|
@worker.w3dhub_api.fetch_package(manifest_package, path: file_path)
|
||||||
@worker.w3dhub_api.fetch_package("TODO")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if result.okay?
|
if result.okay?
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
result.data = true
|
result.data = true
|
||||||
|
else
|
||||||
|
result.error = response.read
|
||||||
end
|
end
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
result.error = e
|
result.error = e
|
||||||
@@ -265,8 +267,23 @@ module W3DHubLauncher
|
|||||||
fetch("#{@access_token ? PRIMARY_W3DHUB_API_ENDPOINT : ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-package-details", method: :post, body: body, headers: headers(form_encoded: true))
|
fetch("#{@access_token ? PRIMARY_W3DHUB_API_ENDPOINT : ALTERNATIVE_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-package-details", method: :post, body: body, headers: headers(form_encoded: true))
|
||||||
end
|
end
|
||||||
|
|
||||||
def download_package()
|
def fetch_package(manifest_package, path:, range: 0)
|
||||||
download()
|
body = URI.encode_www_form(
|
||||||
|
"data": JSON.dump({
|
||||||
|
category: manifest_package.category,
|
||||||
|
subcategory: manifest_package.subcategory,
|
||||||
|
name: manifest_package.name,
|
||||||
|
version: manifest_package.version
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
download(
|
||||||
|
"#{W3DHubApi::PRIMARY_W3DHUB_API_ENDPOINT}/apis/launcher/1/get-package",
|
||||||
|
path: path,
|
||||||
|
method: :post,
|
||||||
|
body: body,
|
||||||
|
headers: headers(form_encoded: true, range: range <= 0 ? nil : range)
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user