Write paths.ini, fix a few issues

This commit is contained in:
2026-09-14 18:42:13 -05:00
parent 73a9a80a34
commit 1d3164da72
3 changed files with 43 additions and 14 deletions

View File

@@ -68,7 +68,7 @@ module W3DHubLauncher
def extended_data(key, default) def extended_data(key, default)
v = @extended_data&.find { |d| d.name == key }&.value v = @extended_data&.find { |d| d.name == key }&.value
if v.nil? if v.nil?
v = @_app.extended_data(key, value) v = @_app.extended_data(key, default)
return default if v.nil? return default if v.nil?
end end

View File

@@ -155,6 +155,8 @@ module W3DHubLauncher
end end
end.flatten end.flatten
return if packages.empty?
result = @worker.w3dhub_api.fetch_package_details(packages) result = @worker.w3dhub_api.fetch_package_details(packages)
unless result.okay? unless result.okay?
@@ -242,13 +244,35 @@ module W3DHubLauncher
end end
def remove_deleted_files def remove_deleted_files
@deleted_manifest_files.each do |manifest_file|
file_path = normalize_path(manifest_file.name)
if File.exist?(file_path) && !File.directory?(file_path)
puts "Removing file: #{file_path}"
File.delete(file_path)
remove_from_file_index(file_path)
end
end
end end
def write_paths_ini def write_paths_ini
File.open(normalize_path("data/paths.ini"), "w") do |file|
file.puts("[paths]")
file.puts("RegBase=W3D Hub")
file.puts("RegClient=#{@application.category}\\#{@application.id}-#{@channel.id}")
file.puts("RegFDS=#{@application.category}\\#{@application.id}-#{@channel.id}-server")
file.puts("FileBase=W3D Hub");
file.puts("FileClient=#{@application.category}\\#{@application.id}-#{@channel.id}")
file.puts("FileFDS=#{@application.category}\\#{@application.id}-#{@channel.id}-server")
file.puts("UseRenFolder=#{@channel.extended_data("usesRenFolder", false)}")
end
end end
# updated, and moved applications will overwrite existing application data in settings # updated, and moved applications will overwrite existing application data in settings
def mark_application_installed def mark_application_installed
puts "APPLICATION: #{@application.name} #{@application.id}:#{@channel.id}:#{@target_version} installed."
end end
def mark_application_uninstalled def mark_application_uninstalled
@@ -269,9 +293,9 @@ module W3DHubLauncher
directory = @worker.settings.preferences.launcher_package_cache_directory directory = @worker.settings.preferences.launcher_package_cache_directory
if package.version? if package.version?
format("%s/%s/%s", directory, package.version.to_s, package.name) format("%s/%s/%s/%s", directory, @application.id, package.version.to_s, package.name)
else else
format("%s/%s", directory, package.name) format("%s/%s/%s", directory, @application.id, package.name)
end end
end end
@@ -282,8 +306,8 @@ module W3DHubLauncher
def create_directory(path) def create_directory(path)
path.gsub!("\\", "/") path.gsub!("\\", "/")
# directory already exists, SKIP! # directory doesn't exists, create it!
unless File.exist?(path) && File.directory?(path) && (file_index = @file_index[path.downcase]) unless File.directory?(path)
FileUtils.mkdir_p(path) FileUtils.mkdir_p(path)
add_directory_to_file_index(path) add_directory_to_file_index(path)
@@ -375,24 +399,29 @@ module W3DHubLauncher
return result unless result.okay? return result unless result.okay?
response = JSON.parse(result.data) response = JSON.parse(result.data)
package_details = response["packages"]&.map { |item| Worker::Api::LegacyManifestPackage.new(item) }&.first manifest_package = response["packages"]&.map { |item| Worker::Api::LegacyManifestPackage.new(item) }&.first
if package_details.nil? || package_details.error? if manifest_package.nil? || manifest_package.error?
pp package_details pp manifest_package
abort_task!("Failed to fetch package details for manifest #{version}") abort_task!("Failed to fetch package details for manifest #{version}")
end end
# FIXME: check if locally downloaded manifest is still valid, if present. # FIXME: check if locally downloaded manifest is still valid, if present.
result = if package_details.download_url file_path = package_cache_path(manifest_package)
@worker.w3dhub_api.download(package_details.download_url, path: "manifest-#{version}.xml")
create_directory(File.dirname(file_path))
result = if manifest_package.download_url
@worker.w3dhub_api.download(manifest_package.download_url, path: file_path)
else else
# TODO xD # TODO xD
@worker.w3dhub_api.fetch_package("TODO") @worker.w3dhub_api.fetch_package("TODO")
end end
if result.okay? if result.okay?
return Worker::Api::LegacyManifest.new("manifest-#{version}.xml") return Worker::Api::LegacyManifest.new(package_cache_path(manifest_package))
else else
pp result
abort_task!("Failed to fetch manifest #{version}") abort_task!("Failed to fetch manifest #{version}")
end end
end end

View File

@@ -67,9 +67,9 @@ module W3DHubLauncher
content_length = response.headers["content-length"] || 0 content_length = response.headers["content-length"] || 0
total_downloaded_bytes = 0 total_downloaded_bytes = 0
range = headers.find { |key, value| key == "range" }&.last&.split("=")&.last&.split("-")&.first range = Integer(headers.find { |key, value| key == "range" }&.last&.split("=")&.last&.split("-")&.first || 0)
File.open(path, range ? "r+b" : "wb") do |file| File.open(path, range.positive? ? "r+b" : "wb") do |file|
file.pos = Integer(range) if range file.pos = range if range.positive?
response.each do |chunk| response.each do |chunk|
file.write(chunk) file.write(chunk)