mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2026-11-04 09:04:04 +00:00
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:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,6 +2,7 @@ module W3DHubLauncher
|
||||
class Task
|
||||
class InstallApplication < Task
|
||||
def setup
|
||||
@task_verb = "Installing".freeze
|
||||
end
|
||||
|
||||
def execute
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
module W3DHubLauncher
|
||||
class Task
|
||||
class RepairApplication < InstallApplication
|
||||
def setup
|
||||
super
|
||||
|
||||
@task_verb = "Repairing".freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
module W3DHubLauncher
|
||||
class Task
|
||||
class UpdateApplication < InstallApplication
|
||||
def setup
|
||||
super
|
||||
|
||||
@task_verb = "Updating".freeze
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user