Initial work on game verification

This commit is contained in:
2021-12-23 18:15:11 -06:00
parent 570652e40d
commit f1e7d430b6
2 changed files with 46 additions and 25 deletions

View File

@@ -405,28 +405,41 @@ class W3DHub
puts "#{@app_id} has been installed." puts "#{@app_id} has been installed."
end end
def verify_files(_) def verify_files(manifests, packages)
# TODO: Check extracted game files or just re-extract everything? path = Cache.install_path(@application, @channel)
accepted_files = {}
rejected_files = []
# Zip.on_exists_proc = true # Overwrite existing files manifests.each do |manifest|
# zip_file = Zip::InputStream.new(File.open(package_path)) manifest.files.each do |file|
# while (entry = zip_file.get_next_entry) file_path = "#{path}/#{file.name.gsub('\\', '/')}"
# extract_path = "#{path}/#{entry.name}" unless File.exists?(file_path)
# manifest_file = @files["#{entry.name}:#{package.version}"] rejected_files << file
puts "[#{manifest.version}] File missing: #{file_path}"
next
end
# if manifest_file.removed? next if accepted_files.key?(file.name)
# puts " !skipped: #{extract_path}"
# else
# target_file_exits = File.exist?(extract_path)
# next if target_file_exits # && Digest::SHA256.new.hexdigest(File.read(extract_path)) == manifest_file.checksum
# puts " #{path}/#{extract_path}" digest = Digest::SHA256.new
# Cache.create_directories(extract_path) unless target_file_exits f = File.open(file_path)
# entry.extract(extract_path) while (chunk = f.read(32_000_000))
# end digest.update(chunk)
# end end
f.close
if digest.hexdigest.upcase == file.checksum.upcase
accepted_files[file.name] = manifest.version
puts "[#{manifest.version}] Verified file: #{file_path}"
else
rejected_files << file
puts "[#{manifest.version}] File failed Verification: #{file_path}"
end
end
end
end end
############# #############

View File

@@ -5,14 +5,22 @@ class W3DHub
:repairer :repairer
end end
def exec_task def execute_task
# fetch manifests fail_fast
# load manifests return false if failed?
# run presence and checksum checks
# extract and re/place broken/missing files manifests = fetch_manifests
# if a large number of files are missing from a single package return false if failed?
# simply reextract the whole thing
# mark application as installed/repaired packages = build_package_list(manifests)
return false if failed?
verify_files(manifests, packages)
return false if failed?
# pp packages.select { |pkg| pkg.name == "misc" }
true
end end
end end
end end