Brought back Excon for package downloading as the method recommended by async-http is unreliable, added support for importing games, repairer and updater tasks are both now simple subclasses of installer, implemented verify_files for checking installed files to prune download package list (currently causes Api.package_details to fail..., so disabled for now), misc. changes.

This commit is contained in:
2021-12-28 17:55:40 -06:00
parent f4aa666386
commit 82add3cc9d
12 changed files with 221 additions and 132 deletions

View File

@@ -1,10 +1,47 @@
class W3DHub
class ApplicationManager
class Importer < Task
def initialize(app_id, channel, path = nil)
super(app_id, channel)
def type
:importer
end
@path = path
def execute_task
path = ask_file
unless File.exist?(path) && !File.directory?(path)
fail!("File #{path.inspect} does not exist or is a directory")
fail_silently! if path.nil? || path&.length&.zero? # User likely canceled the file selection
end
return false if failed?
Store.application_manager.imported!(self, path)
true
end
def ask_file(title: "Open File", filter: "*game*.exe")
if W3DHub.unix?
# search for command
cmds = %w{ zenity matedialog qarma kdialog }
command = cmds.find do |cmd|
cmd if system("which #{cmd}")
end
path = case File.basename(command)
when "zenity", "matedialog", "qarma"
`#{command} --file-selection --title "#{title}" --file-filter "#{filter}"`
when "kdialog"
`#{command} --title "#{title}" --getopenfilename . "#{filter}"`
else
raise "No known command found for system file selection dialog!"
end
path.strip
else
raise NotImplementedError
end
end
end
end

View File

@@ -15,6 +15,9 @@ class W3DHub
packages = build_package_list(manifests)
return false if failed?
# verify_files(manifests, packages)
# return false if failed?
fetch_packages(packages)
return false if failed?

View File

@@ -1,27 +1,27 @@
class W3DHub
class ApplicationManager
class Repairer < Task
class Repairer < Installer
def type
:repairer
end
def execute_task
fail_fast
return false if failed?
# def execute_task
# fail_fast
# return false if failed?
manifests = fetch_manifests
return false if failed?
# manifests = fetch_manifests
# return false if failed?
packages = build_package_list(manifests)
return false if failed?
# packages = build_package_list(manifests)
# return false if failed?
verify_files(manifests, packages)
return false if failed?
# verify_files(manifests, packages)
# return false if failed?
# pp packages.select { |pkg| pkg.name == "misc" }
# # pp packages.select { |pkg| pkg.name == "misc" }
true
end
# true
# end
end
end
end