Name partially downloaded cbz files .part (#90)

This commit is contained in:
Alex Ling 2020-07-16 13:16:36 +00:00
parent cd7782ba1e
commit 5be4f51d7e

View File

@ -319,7 +319,7 @@ module MangaDex
unless File.exists? manga_dir
Dir.mkdir_p manga_dir
end
zip_path = File.join manga_dir, "#{job.title}.cbz"
zip_path = File.join manga_dir, "#{job.title}.cbz.part"
# Find the number of digits needed to store the number of pages
len = Math.log10(chapter.pages.size).to_i + 1
@ -369,9 +369,12 @@ module MangaDex
Logger.debug "Download completed. " \
"#{fail_count}/#{page_jobs.size} failed"
writer.close
Logger.debug "cbz File created at #{zip_path}"
filename = File.join File.dirname(zip_path), File.basename(zip_path,
".part")
File.rename zip_path, filename
Logger.debug "cbz File created at #{filename}"
zip_exception = validate_archive zip_path
zip_exception = validate_archive filename
if !zip_exception.nil?
@queue.add_message "The downloaded archive is corrupted. " \
"Error: #{zip_exception}", job