Application updating and repair is now possible, save news and applications listing to cache directory instead of current working directory, added support for application unlinking, misc. other changes

This commit is contained in:
2026-10-07 22:54:42 -05:00
parent bdf678342e
commit a7e1378f55
17 changed files with 285 additions and 64 deletions

View File

@@ -100,6 +100,11 @@ module W3DHubLauncher
def self.uninstall_application(app_id, channel_id, &block)
Worker::Request.new(:task_uninstall_application, { app_id: app_id, channel_id: channel_id }, &block)
end
# request unlinking of application
def self.unlink_application(app_id, channel_id, &block)
Worker::Request.new(:unlink_application, { app_id: app_id, channel_id: channel_id }, &block)
end
end
end
end

View File

@@ -80,6 +80,10 @@ module W3DHubLauncher
extended_data("serverchannel", @id)
end
def update_available?(current_version)
current_version < @version
end
def to_json(context = nil)
{
"id": @id,

View File

@@ -41,6 +41,22 @@ module W3DHubLauncher
applications.find { |app| app.id == app_id && app.channel == channel_id }
end
def add_or_update_application(application)
index = applications.index { |app| app.id == application.id && app.channel == application.channel }
if index
applications[index] = application
else
applications << application
end
application
end
def remove_application(application)
applications.delete(application)
end
# User explictly set options
class Preferences
SCHEMA = 0

View File

@@ -6,6 +6,7 @@ module W3DHubLauncher
IndexedFile = Data.define(:type, :path)
attr_reader :request_id, :application, :channel, :installed_version, :target_version
attr_reader :status
def initialize(request_id:, application:, channel:, installed_version:, target_version:)
@request_id = request_id
@@ -16,6 +17,8 @@ module W3DHubLauncher
pp self
@status = Worker::Request::STATUS_PENDING
# caching mechinism for file path normalization
@file_index = {}
# manifests!
@@ -36,19 +39,28 @@ module W3DHubLauncher
end
def start(worker)
return unless status == Worker::Request::STATUS_PENDING
@worker = worker
@installation_directory ||= application_target_installation_directory
update_status(label: "Starting...", fraction: 0.0)
execute
@status = Worker::Request::STATUS_BUSY
v = execute
@status = Worker::Request::STATUS_COMPLETE
v
end
def abort_task!(reason = "")
puts reason
message_requester(Worker::Request::STATUS_ERROR, data: nil, error: reason)
@status = Worker::Request::STATUS_ERROR
raise reason
end
@@ -120,6 +132,8 @@ module W3DHubLauncher
@required_manifest_files = @manifest_files.clone
cached_checksums = {}
# Process manifest game files in NEWEST to OLDEST order so that we don't erroneously flag
# valid files as invalid due to an OLDER version of the file being checked FIRST.
@manifest_files.reverse.each do |file|
@@ -133,13 +147,17 @@ module W3DHubLauncher
next unless File.exist?(file_path) # && !File.directory?(file_path)
puts "verifying #{file_path}..."
checksum = Digest::SHA256.file(file_path).hexdigest.upcase
checksum = cached_checksums[file_path] || Digest::SHA256.file(file_path).hexdigest.upcase
cached_checksums[file_path] ||= checksum
if checksum == file.checksum
@required_manifest_files.delete(file)
# remove irrelevant older versions of the file from consideration
@required_manifest_files.delete_if { |f| f.name.casecmp?(file.name) && f.version < file.version }
puts " verified:#{file.version}"
else
puts " failed verification:#{file.version}"
end
end
end
@@ -279,12 +297,14 @@ module W3DHubLauncher
timestamp: Time.now.to_i
)
@status = Worker::Request::STATUS_COMPLETE
message_requester(Worker::Request::STATUS_COMPLETE, data: { application: app })
puts "APPLICATION: #{@application.name} #{@application.id}:#{@channel.id}:#{@target_version} installed."
end
def mark_application_uninstalled
@status = Worker::Request::STATUS_COMPLETE
message_requester(Worker::Request::STATUS_COMPLETE, data: {})
end
@@ -295,7 +315,7 @@ module W3DHubLauncher
end
def update_status(label:, fraction:)
message_requester(data: { status: { title: "TASK #{@application.name} (#{@channel.name})", label: label, fraction: fraction } } )
message_requester(data: { status: { title: "#{@task_verb} #{@application.name} (#{@channel.name})", label: label, fraction: fraction } } )
end
def application_target_installation_directory

View File

@@ -2,6 +2,7 @@ module W3DHubLauncher
class Task
class InstallApplication < Task
def setup
@task_verb = "Installing".freeze
end
def execute

View File

@@ -0,0 +1,11 @@
module W3DHubLauncher
class Task
class RepairApplication < InstallApplication
def setup
super
@task_verb = "Repairing".freeze
end
end
end
end

View File

@@ -0,0 +1,11 @@
module W3DHubLauncher
class Task
class UpdateApplication < InstallApplication
def setup
super
@task_verb = "Updating".freeze
end
end
end
end