Use Gzip instead of Zip

This commit is contained in:
Leeingnyo 2021-09-12 18:01:16 +09:00
parent f5933a48d9
commit 8f1383a818

View File

@ -10,8 +10,9 @@ class Library
path = Config.current.library_path path = Config.current.library_path
instance_file_path = File.join path, "library.yml.zip" instance_file_path = File.join path, "library.yml.zip"
writer = Compress::Zip::Writer.new instance_file_path writer = Compress::Gzip::Writer.new instance_file_path,
writer.add "instance.yml", self.to_yaml Compress::Gzip::BEST_COMPRESSION
writer.write self.to_yaml.to_slice
writer.close writer.close
end end
@ -22,18 +23,10 @@ class Library
return unless File.exists? instance_file_path return unless File.exists? instance_file_path
Logger.debug "Load library instance" Logger.debug "Load library instance"
zip_file = Compress::Zip::File.new instance_file_path
instance_file = zip_file.entries.find do |entry|
entry.filename == "instance.yml"
end
if instance_file.nil?
zip_file.close
return
end
is_loaded = false is_loaded = false
begin begin
instance_file.open do |content| Compress::Gzip::Reader.open instance_file_path do |content|
@@default = Library.from_yaml content @@default = Library.from_yaml content
end end
is_loaded = true is_loaded = true
@ -41,8 +34,6 @@ class Library
Logger.error e Logger.error e
end end
zip_file.close
if is_loaded if is_loaded
Library.default.register_jobs Library.default.register_jobs
end end