mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-09-19 06:43:55 +00:00
Initial work on manifest fetching and parsing
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
pkg/
|
pkg/
|
||||||
*.json
|
*.json
|
||||||
|
*.xml
|
||||||
data/cache/*
|
data/cache/*
|
||||||
!data/cache/.gitkeep
|
!data/cache/.gitkeep
|
||||||
data/logs/*
|
data/logs/*
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
require "json"
|
require "json"
|
||||||
require "digest/sha2"
|
require "digest/sha2"
|
||||||
|
|
||||||
module W3DHubBackend
|
module W3DHubLauncher
|
||||||
class Worker
|
class Worker
|
||||||
class Api
|
class Api
|
||||||
class LegacyManifestPackage
|
class LegacyManifestPackage
|
||||||
attr_reader :category, :subcategory, :version, :name, :error, :file_size,
|
attr_reader :category, :subcategory, :version, :name, :error, :file_size,
|
||||||
:checksum_chunk_size, :sha256_checksum, :checksum_chunks
|
:checksum_chunk_size, :sha256_checksum, :checksum_chunks, :download_url
|
||||||
|
|
||||||
def initialize(hash)
|
def initialize(hash)
|
||||||
@category = hash["category"]
|
@category = hash["category"]
|
||||||
@@ -18,6 +18,7 @@ module W3DHubBackend
|
|||||||
@checksum_chunk_size = Integer(hash["checksum-size"] || 0)
|
@checksum_chunk_size = Integer(hash["checksum-size"] || 0)
|
||||||
@sha256_checksum = hash["checksum"]
|
@sha256_checksum = hash["checksum"]
|
||||||
@checksum_chunks = hash["checksum-chunks"]
|
@checksum_chunks = hash["checksum-chunks"]
|
||||||
|
@download_url = hash["download_url"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def error?
|
def error?
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ module W3DHubLauncher
|
|||||||
|
|
||||||
pp self
|
pp self
|
||||||
|
|
||||||
|
@manifests = {}
|
||||||
|
|
||||||
setup
|
setup
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -24,61 +26,83 @@ module W3DHubLauncher
|
|||||||
end
|
end
|
||||||
|
|
||||||
def fetch_manifests(version = @target_version)
|
def fetch_manifests(version = @target_version)
|
||||||
result = fetch_manifest(version)
|
while (manifest = fetch_manifest(version))
|
||||||
if result.okay?
|
@manifests[version] = manifest
|
||||||
pp result
|
|
||||||
else
|
version = manifest.base_version
|
||||||
pp [:error, result]
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def fetch_manifest(version)
|
def fetch_manifest(version)
|
||||||
@worker.w3dhub_api.fetch_package_details([{category: "games", subcategory: @application.id, name: "manifest.xml", version: version }])
|
result = @worker.w3dhub_api.fetch_package_details([{category: "games", subcategory: @application.id, name: "manifest.xml", version: version }])
|
||||||
|
|
||||||
|
return false unless result.okay?
|
||||||
|
|
||||||
|
response = JSON.parse(result.data)
|
||||||
|
pp response
|
||||||
|
pp package_details = response["packages"]&.map { |item| Worker::Api::LegacyManifestPackage.new(item) }&.first
|
||||||
|
|
||||||
|
return false unless package_details
|
||||||
|
return false if package_details.error?
|
||||||
|
|
||||||
|
# FIXME: check if locally downloaded manifest is still valid, if present.
|
||||||
|
result = if package_details.download_url
|
||||||
|
@worker.w3dhub_api.download(package_details.download_url, path: "manifest-#{version}.xml")
|
||||||
|
else
|
||||||
|
# TODO xD
|
||||||
|
@worker.w3dhub_api.fetch_package("TODO")
|
||||||
|
end
|
||||||
|
|
||||||
|
pp result
|
||||||
|
|
||||||
|
return Worker::Api::LegacyManifest.new("manifest-#{version}.xml") if result.okay?
|
||||||
|
|
||||||
|
false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def execute_task
|
# def execute_task
|
||||||
show_application_taskbar
|
# show_application_taskbar
|
||||||
|
|
||||||
fail_fast
|
# fail_fast
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
fetch_manifests
|
# fetch_manifests
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
build_package_list
|
# build_package_list
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
remove_deleted_files
|
# remove_deleted_files
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
verify_files
|
# verify_files
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
fetch_packages
|
# fetch_packages
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
verify_packages
|
# verify_packages
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
unpack_packages
|
# unpack_packages
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
create_wine_prefix
|
# create_wine_prefix
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
install_dependencies
|
# install_dependencies
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
write_paths_ini
|
# write_paths_ini
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
mark_application_installed
|
# mark_application_installed
|
||||||
return false if failed?
|
# return false if failed?
|
||||||
|
|
||||||
sleep 1
|
# sleep 1
|
||||||
hide_application_taskbar
|
# hide_application_taskbar
|
||||||
|
|
||||||
true
|
# true
|
||||||
end
|
# end
|
||||||
|
|||||||
Reference in New Issue
Block a user