Set status as "Error" if downloaded zip is invalid

(#29)
This commit is contained in:
Alex Ling
2020-04-08 10:30:29 +00:00
parent fc6a33e5fd
commit 39f4897fc5
3 changed files with 28 additions and 18 deletions

View File

@@ -81,3 +81,15 @@ end
def compare_alphanumerically(a : String, b : String)
compare_alphanumerically split_by_alphanumeric(a), split_by_alphanumeric(b)
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
def validate_zip(path : String) : Exception?
file = Zip::File.new path
file.close
return
rescue e
e
end