mirror of
https://github.com/hkalexling/Mango.git
synced 2026-03-20 00:00:48 -04:00
@@ -106,7 +106,13 @@ class Title
|
||||
next
|
||||
end
|
||||
if [".zip", ".cbz"].includes? File.extname path
|
||||
next if !valid_zip path
|
||||
zip_exception = validate_zip path
|
||||
unless zip_exception.nil?
|
||||
@logger.warn "File #{path} is corrupted or is not a valid zip " \
|
||||
"archive. Ignoring it."
|
||||
@logger.debug "Zip error: #{zip_exception}"
|
||||
next
|
||||
end
|
||||
entry = Entry.new path, self, @id, storage
|
||||
@entries << entry if entry.pages > 0
|
||||
end
|
||||
@@ -171,20 +177,6 @@ class Title
|
||||
@entries.size + @title_ids.size
|
||||
end
|
||||
|
||||
# When downloading from MangaDex, the zip/cbz file would not be valid
|
||||
# before the download is completed. If we scan the zip file,
|
||||
# Entry.new would throw, so we use this method to check before
|
||||
# constructing Entry
|
||||
private def valid_zip(path : String)
|
||||
file = Zip::File.new path
|
||||
file.close
|
||||
true
|
||||
rescue
|
||||
@logger.warn "File #{path} is corrupted or is not a valid zip " \
|
||||
"archive. Ignoring it."
|
||||
false
|
||||
end
|
||||
|
||||
def get_entry(eid)
|
||||
@entries.find { |e| e.id == eid }
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user