mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-05 04:15:35 -04:00
When an invalid zip file is found, instead of ignoring it silently, log
a warning message
This commit is contained in:
parent
dc3bbd10d6
commit
5645f272df
@ -61,9 +61,9 @@ end
|
|||||||
|
|
||||||
class Title
|
class Title
|
||||||
JSON.mapping dir: String, entries: Array(Entry), title: String,
|
JSON.mapping dir: String, entries: Array(Entry), title: String,
|
||||||
id: String, encoded_title: String, mtime: Time
|
id: String, encoded_title: String, mtime: Time, logger: MLogger
|
||||||
|
|
||||||
def initialize(dir : String, storage)
|
def initialize(dir : String, storage, @logger : MLogger)
|
||||||
@dir = dir
|
@dir = dir
|
||||||
@id = storage.get_id @dir, true
|
@id = storage.get_id @dir, true
|
||||||
@title = File.basename dir
|
@title = File.basename dir
|
||||||
@ -91,6 +91,8 @@ class Title
|
|||||||
file.close
|
file.close
|
||||||
return true
|
return true
|
||||||
rescue
|
rescue
|
||||||
|
@logger.warn "File #{path} is corrupted or is not a valid zip "\
|
||||||
|
"archive. Ignoring it."
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -200,7 +202,7 @@ class Library
|
|||||||
end
|
end
|
||||||
@titles = (Dir.entries @dir)
|
@titles = (Dir.entries @dir)
|
||||||
.select { |path| File.directory? File.join @dir, path }
|
.select { |path| File.directory? File.join @dir, path }
|
||||||
.map { |path| Title.new File.join(@dir, path), @storage }
|
.map { |path| Title.new File.join(@dir, path), @storage, @logger }
|
||||||
.select { |title| !title.entries.empty? }
|
.select { |title| !title.entries.empty? }
|
||||||
.sort { |a, b| a.title <=> b.title }
|
.sort { |a, b| a.title <=> b.title }
|
||||||
@logger.debug "Scan completed"
|
@logger.debug "Scan completed"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user