More work on Task towards getting app installation workin'

This commit is contained in:
2026-09-12 19:41:27 -05:00
parent 2cf8146553
commit db0dd9fc7c
3 changed files with 91 additions and 22 deletions

View File

@@ -10,8 +10,8 @@ module W3DHubLauncher
@game = root["game"]
@type = root["type"]
@version = root["version"]
@base_version = root["baseVersion"]
@version = root["version"] ? Gem::Version.new(root["version"]) : nil
@base_version = root["baseVersion"] ? Gem::Version.new(root["baseVersion"]) : nil
@files = []
@dependencies = []
@@ -49,7 +49,7 @@ module W3DHubLauncher
@name = @data["name"]
@checksum = @data["checksum"]
@package = @data["package"]
@removed_since = @data["removedsince"]
@removed_since = @data["removedsince"] ? Gem::Version.new(@data["removedsince"]) : nil
xml.elements.each("Patch") do |patch|
@patch = true
@@ -63,7 +63,7 @@ module W3DHubLauncher
end
end
@version = version
@version = version ? Gem::Version.new(version) : nil
end
def removed?

View File

@@ -25,25 +25,91 @@ module W3DHubLauncher
execute
end
def abort_task!(reason = "")
puts reason
raise reason
end
# high level methods
def fetch_manifests(version = @target_version)
while (manifest = fetch_manifest(version))
@manifests[version] = manifest
version = manifest.base_version
break unless version
break if manifest.full?
end
end
def build_package_list
channel_manifests = []
version = @target_version
while(manifest = @manifests[version])
channel_manifests << manifest
break if manifest.full?
version = manifest.base_version
end
files = []
deleted_files = []
channel_manifests.reverse.each do |manifest|
manifest.files.each do |file|
if file.removed?
files.delete_if { |f| f.name.casecmp?(file.name) }
deleted_files << file
next
end
# remove files that are total replacements, not patches
files.delete_if { |f| f.name.casecmp?(file.name) } unless file.patch?
# add file to file list
files << file
end
end
pp [:files, files.map(&:name), :deleted_files, deleted_files.map(&:name)]
end
def remove_deleted_files
end
def verify_files
end
def fetch_packages
end
def install_packages
end
# helper functions
def fetch_manifest(version)
result = @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?
return result unless result.okay?
response = JSON.parse(result.data)
pp response
pp package_details = response["packages"]&.map { |item| Worker::Api::LegacyManifestPackage.new(item) }&.first
package_details = response["packages"]&.map { |item| Worker::Api::LegacyManifestPackage.new(item) }&.first
return false unless package_details
return false if package_details.error?
if package_details.nil? || package_details.error?
pp package_details
abort_task!("Failed to fetch package details for manifest #{version}")
end
# FIXME: check if locally downloaded manifest is still valid, if present.
result = if package_details.download_url
@@ -53,11 +119,11 @@ module W3DHubLauncher
@worker.w3dhub_api.fetch_package("TODO")
end
pp result
return Worker::Api::LegacyManifest.new("manifest-#{version}.xml") if result.okay?
false
if result.okay?
return Worker::Api::LegacyManifest.new("manifest-#{version}.xml")
else
abort_task!("Failed to fetch manifest #{version}")
end
end
end
end

View File

@@ -11,15 +11,18 @@ module W3DHubLauncher
# fetch manifests for currently installed version
# AND the target version so we can detect files that need to be removed
# between versions
manifests_result = fetch_manifests
abort_task!(manifests_result) unless manifests_result.okay?
fetch_manifests
package_list_result = build_package_list(manifests_result)
abort_task!(package_list_result) unless package_list_result.okay?
# remove_deleted_files
# build list of packages we'll need to download
build_package_list
verify_files
fetch_packages
install_packages
remove_deleted_files
end
end
end