From 74a2ca652b14a02d924c858cfb6c531516e7cbc6 Mon Sep 17 00:00:00 2001 From: cyberarm Date: Tue, 30 Nov 2021 14:00:51 -0600 Subject: [PATCH] Removed usages of eager_load, probably fixed application launching weirdness --- lib/api.rb | 4 ++-- lib/application_manager.rb | 4 +++- lib/application_manager/task.rb | 4 ++-- lib/cache.rb | 3 ++- lib/mixer.rb | 4 ++-- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/api.rb b/lib/api.rb index 8561114..0574c60 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -8,7 +8,7 @@ class W3DHub #! === W3D Hub API === !# 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 # FORMAT: JSON @@ -171,7 +171,7 @@ class W3DHub #! === Server List API === !# 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 # FORMAT: JSON diff --git a/lib/application_manager.rb b/lib/application_manager.rb index f5ed169..c48e8bc 100644 --- a/lib/application_manager.rb +++ b/lib/application_manager.rb @@ -143,7 +143,9 @@ class W3DHub def run(app_id, channel, *args) 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) end end diff --git a/lib/application_manager/task.rb b/lib/application_manager/task.rb index 6c7487a..ece19d1 100644 --- a/lib/application_manager/task.rb +++ b/lib/application_manager/task.rb @@ -525,7 +525,7 @@ class W3DHub system("#{W3DHub.tar_command} -xf \"#{package_path}\" -C \"#{temp_path}\"") 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) 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 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? patch_info[:removedFiles].each do |file| diff --git a/lib/cache.rb b/lib/cache.rb index e717ecf..fbd0199 100644 --- a/lib/cache.rb +++ b/lib/cache.rb @@ -13,7 +13,7 @@ class W3DHub if File.exist?(path) path else - response = Excon.get(uri) + response = Excon.get(uri, tcp_nodelay: true) if response.status == 200 File.open(path, "wb") do |f| @@ -71,6 +71,7 @@ class W3DHub # Create a new connection due to some weirdness somewhere in Excon response = Excon.post( "#{Api::ENDPOINT}/apis/launcher/1/get-package", + tcp_nodelay: true, headers: Api::DEFAULT_HEADERS.merge(headers), body: "data=#{JSON.dump({ category: package.category, subcategory: package.subcategory, name: package.name, version: package.version })}", chunk_size: 4_000_000, diff --git a/lib/mixer.rb b/lib/mixer.rb index 58bcf50..6f02340 100644 --- a/lib/mixer.rb +++ b/lib/mixer.rb @@ -135,7 +135,7 @@ class W3DHub class Reader 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 @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 class Patcher 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) @temp_file = File.open(temp_file, "a+b") @buffer_size = buffer_size