Initial work on manifest fetching and parsing

This commit is contained in:
2026-09-11 23:55:04 -05:00
parent af438e35bc
commit 2cf8146553
3 changed files with 64 additions and 38 deletions

1
.gitignore vendored
View File

@@ -1,5 +1,6 @@
pkg/
*.json
*.xml
data/cache/*
!data/cache/.gitkeep
data/logs/*

View File

@@ -1,12 +1,12 @@
require "json"
require "digest/sha2"
module W3DHubBackend
module W3DHubLauncher
class Worker
class Api
class LegacyManifestPackage
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)
@category = hash["category"]
@@ -18,6 +18,7 @@ module W3DHubBackend
@checksum_chunk_size = Integer(hash["checksum-size"] || 0)
@sha256_checksum = hash["checksum"]
@checksum_chunks = hash["checksum-chunks"]
@download_url = hash["download_url"]
end
def error?

View File

@@ -11,6 +11,8 @@ module W3DHubLauncher
pp self
@manifests = {}
setup
end
@@ -24,61 +26,83 @@ module W3DHubLauncher
end
def fetch_manifests(version = @target_version)
result = fetch_manifest(version)
if result.okay?
pp result
else
pp [:error, result]
while (manifest = fetch_manifest(version))
@manifests[version] = manifest
version = manifest.base_version
end
end
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
def execute_task
show_application_taskbar
# def execute_task
# show_application_taskbar
fail_fast
return false if failed?
# fail_fast
# return false if failed?
fetch_manifests
return false if failed?
# fetch_manifests
# return false if failed?
build_package_list
return false if failed?
# build_package_list
# return false if failed?
remove_deleted_files
return false if failed?
# remove_deleted_files
# return false if failed?
verify_files
return false if failed?
# verify_files
# return false if failed?
fetch_packages
return false if failed?
# fetch_packages
# return false if failed?
verify_packages
return false if failed?
# verify_packages
# return false if failed?
unpack_packages
return false if failed?
# unpack_packages
# return false if failed?
create_wine_prefix
return false if failed?
# create_wine_prefix
# return false if failed?
install_dependencies
return false if failed?
# install_dependencies
# return false if failed?
write_paths_ini
return false if failed?
# write_paths_ini
# return false if failed?
mark_application_installed
return false if failed?
# mark_application_installed
# return false if failed?
sleep 1
hide_application_taskbar
# sleep 1
# hide_application_taskbar
true
end
# true
# end