case desensitize unzip

This commit is contained in:
The Unnamed Engineer
2025-08-14 18:59:27 -04:00
committed by Cyberarm
parent 5bafc77d97
commit 0c906464f0

View File

@@ -750,12 +750,19 @@ class W3DHub
def unzip(package_path, path) def unzip(package_path, path)
stream = Zip::InputStream.new(File.open(package_path)) stream = Zip::InputStream.new(File.open(package_path))
extracted_files = {} # Track files we've already extracted to handle case conflicts
while (entry = stream.get_next_entry) while (entry = stream.get_next_entry)
# Normalize the path to handle case-insensitivity consistently
safe_file_name = normalize_path(entry.name.gsub("\\", "/"))
safe_file_name = entry.name.gsub("\\", "/") # Skip if we've already extracted a file with this normalized path
# Fix borked Data -> data 'cause Windows don't care about capitalization if extracted_files[safe_file_name]
safe_file_name.sub!("Data/", "data/") logger.debug(LOG_TAG) { "Skipping duplicate file (case-insensitive): #{entry.name}" }
next
end
extracted_files[safe_file_name] = true
dir_path = "#{path}/#{File.dirname(safe_file_name)}" dir_path = "#{path}/#{File.dirname(safe_file_name)}"
unless dir_path.end_with?("/.") || Dir.exist?(dir_path) unless dir_path.end_with?("/.") || Dir.exist?(dir_path)