mirror of
https://github.com/cyberarm/w3d_hub_linux_launcher.git
synced 2025-12-16 09:12:35 +00:00
Removed usages of eager_load, probably fixed application launching weirdness
This commit is contained in:
@@ -8,7 +8,7 @@ class W3DHub
|
|||||||
#! === W3D Hub API === !#
|
#! === W3D Hub API === !#
|
||||||
|
|
||||||
ENDPOINT = "https://secure.w3dhub.com"
|
ENDPOINT = "https://secure.w3dhub.com"
|
||||||
W3DHUB_API_CONNECTION = Excon.new(ENDPOINT, persistent: true, connect_timeout: 15)
|
W3DHUB_API_CONNECTION = Excon.new(ENDPOINT, persistent: true, connect_timeout: 15, tcp_nodelay: true)
|
||||||
# Method: POST
|
# Method: POST
|
||||||
# FORMAT: JSON
|
# FORMAT: JSON
|
||||||
|
|
||||||
@@ -171,7 +171,7 @@ class W3DHub
|
|||||||
#! === Server List API === !#
|
#! === Server List API === !#
|
||||||
|
|
||||||
SERVER_LIST_ENDPOINT = "https://gsh.w3dhub.com"
|
SERVER_LIST_ENDPOINT = "https://gsh.w3dhub.com"
|
||||||
SERVER_LIST_CONNECTION = Excon.new(SERVER_LIST_ENDPOINT, persistent: true, connect_timeout: 15)
|
SERVER_LIST_CONNECTION = Excon.new(SERVER_LIST_ENDPOINT, persistent: true, connect_timeout: 15, tcp_nodelay: true)
|
||||||
# Method: GET
|
# Method: GET
|
||||||
# FORMAT: JSON
|
# FORMAT: JSON
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,9 @@ class W3DHub
|
|||||||
|
|
||||||
def run(app_id, channel, *args)
|
def run(app_id, channel, *args)
|
||||||
if (app_data = installed?(app_id, channel))
|
if (app_data = installed?(app_id, channel))
|
||||||
pid = Process.spawn("#{wine_command(app_id, channel)}#{app_data[:install_path]}", *args)
|
application_exe = W3DHub.unix? ? "\"#{app_data[:install_path]}\"" : app_data[:install_path]
|
||||||
|
|
||||||
|
pid = Process.spawn("#{wine_command(app_id, channel)}#{application_exe} #{args.join(' ')}")
|
||||||
Process.detach(pid)
|
Process.detach(pid)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -525,7 +525,7 @@ class W3DHub
|
|||||||
system("#{W3DHub.tar_command} -xf \"#{package_path}\" -C \"#{temp_path}\"")
|
system("#{W3DHub.tar_command} -xf \"#{package_path}\" -C \"#{temp_path}\"")
|
||||||
|
|
||||||
puts " Loading #{temp_path}/#{manifest_file.name}.patch..."
|
puts " Loading #{temp_path}/#{manifest_file.name}.patch..."
|
||||||
patch_mix = W3DHub::Mixer::Reader.new(file_path: "#{temp_path}/#{manifest_file.name}.patch", ignore_crc_mismatches: true, eager_load: true)
|
patch_mix = W3DHub::Mixer::Reader.new(file_path: "#{temp_path}/#{manifest_file.name}.patch", ignore_crc_mismatches: true)
|
||||||
patch_info = JSON.parse(patch_mix.package.files.find { |f| f.name == ".w3dhub.patch" || f.name == ".bhppatch" }.data, symbolize_names: true)
|
patch_info = JSON.parse(patch_mix.package.files.find { |f| f.name == ".w3dhub.patch" || f.name == ".bhppatch" }.data, symbolize_names: true)
|
||||||
|
|
||||||
repaired_path = "#{path}/#{manifest_file.name}"
|
repaired_path = "#{path}/#{manifest_file.name}"
|
||||||
@@ -533,7 +533,7 @@ class W3DHub
|
|||||||
repaired_path = "#{path}/#{manifest_file.name.sub('data', 'Data')}" unless File.exist?(repaired_path) && path
|
repaired_path = "#{path}/#{manifest_file.name.sub('data', 'Data')}" unless File.exist?(repaired_path) && path
|
||||||
|
|
||||||
puts " Loading #{repaired_path}..."
|
puts " Loading #{repaired_path}..."
|
||||||
target_mix = W3DHub::Mixer::Reader.new(file_path: repaired_path, ignore_crc_mismatches: true, eager_load: true)
|
target_mix = W3DHub::Mixer::Reader.new(file_path: repaired_path, ignore_crc_mismatches: true)
|
||||||
|
|
||||||
puts " Removing files..." if patch_info[:removedFiles].size.positive?
|
puts " Removing files..." if patch_info[:removedFiles].size.positive?
|
||||||
patch_info[:removedFiles].each do |file|
|
patch_info[:removedFiles].each do |file|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class W3DHub
|
|||||||
if File.exist?(path)
|
if File.exist?(path)
|
||||||
path
|
path
|
||||||
else
|
else
|
||||||
response = Excon.get(uri)
|
response = Excon.get(uri, tcp_nodelay: true)
|
||||||
|
|
||||||
if response.status == 200
|
if response.status == 200
|
||||||
File.open(path, "wb") do |f|
|
File.open(path, "wb") do |f|
|
||||||
@@ -71,6 +71,7 @@ class W3DHub
|
|||||||
# Create a new connection due to some weirdness somewhere in Excon
|
# Create a new connection due to some weirdness somewhere in Excon
|
||||||
response = Excon.post(
|
response = Excon.post(
|
||||||
"#{Api::ENDPOINT}/apis/launcher/1/get-package",
|
"#{Api::ENDPOINT}/apis/launcher/1/get-package",
|
||||||
|
tcp_nodelay: true,
|
||||||
headers: Api::DEFAULT_HEADERS.merge(headers),
|
headers: Api::DEFAULT_HEADERS.merge(headers),
|
||||||
body: "data=#{JSON.dump({ category: package.category, subcategory: package.subcategory, name: package.name, version: package.version })}",
|
body: "data=#{JSON.dump({ category: package.category, subcategory: package.subcategory, name: package.name, version: package.version })}",
|
||||||
chunk_size: 4_000_000,
|
chunk_size: 4_000_000,
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ class W3DHub
|
|||||||
class Reader
|
class Reader
|
||||||
attr_reader :package
|
attr_reader :package
|
||||||
|
|
||||||
def initialize(file_path:, ignore_crc_mismatches: false, eager_load: false, metadata_only: false, buffer_size: 32_000_000)
|
def initialize(file_path:, ignore_crc_mismatches: false, metadata_only: false, buffer_size: 32_000_000)
|
||||||
@package = Package.new
|
@package = Package.new
|
||||||
|
|
||||||
@buffer = MemoryBuffer.new(file_path: file_path, mode: "r", buffer_size: buffer_size)
|
@buffer = MemoryBuffer.new(file_path: file_path, mode: "r", buffer_size: buffer_size)
|
||||||
@@ -275,7 +275,7 @@ class W3DHub
|
|||||||
# after that is done, replace target file with temp file
|
# after that is done, replace target file with temp file
|
||||||
class Patcher
|
class Patcher
|
||||||
def initialize(patch_file:, target_file:, temp_file:, buffer_size: 32_000_000)
|
def initialize(patch_file:, target_file:, temp_file:, buffer_size: 32_000_000)
|
||||||
@patch_file = Reader.new(file_path: patch_file, eager_load: true)
|
@patch_file = Reader.new(file_path: patch_file)
|
||||||
@target_file = File.open(target_file)
|
@target_file = File.open(target_file)
|
||||||
@temp_file = File.open(temp_file, "a+b")
|
@temp_file = File.open(temp_file, "a+b")
|
||||||
@buffer_size = buffer_size
|
@buffer_size = buffer_size
|
||||||
|
|||||||
Reference in New Issue
Block a user