mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
Use Gzip instead of Zip
This commit is contained in:
parent
f5933a48d9
commit
8f1383a818
@ -10,8 +10,9 @@ class Library
|
||||
path = Config.current.library_path
|
||||
instance_file_path = File.join path, "library.yml.zip"
|
||||
|
||||
writer = Compress::Zip::Writer.new instance_file_path
|
||||
writer.add "instance.yml", self.to_yaml
|
||||
writer = Compress::Gzip::Writer.new instance_file_path,
|
||||
Compress::Gzip::BEST_COMPRESSION
|
||||
writer.write self.to_yaml.to_slice
|
||||
writer.close
|
||||
end
|
||||
|
||||
@ -22,18 +23,10 @@ class Library
|
||||
return unless File.exists? instance_file_path
|
||||
|
||||
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
|
||||
begin
|
||||
instance_file.open do |content|
|
||||
Compress::Gzip::Reader.open instance_file_path do |content|
|
||||
@@default = Library.from_yaml content
|
||||
end
|
||||
is_loaded = true
|
||||
@ -41,8 +34,6 @@ class Library
|
||||
Logger.error e
|
||||
end
|
||||
|
||||
zip_file.close
|
||||
|
||||
if is_loaded
|
||||
Library.default.register_jobs
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user