This commit is contained in:
Nemo 2020-04-04 01:17:31 +05:30
parent 1a5086b2d7
commit 00c80bf8e4
2 changed files with 12 additions and 0 deletions

View File

@ -16,6 +16,11 @@ module Muse::Dl
"#{tmp_path}/chapter-#{id}.pdf"
end
def self.cleanup(tmp_path : String, id : String)
fns = chapter_file_name(id, tmp_path)
File.delete(fns) if File.exists?(fns)
end
def self.save_chapter(tmp_path : String, chapter_id : String, chapter_title : String, cookie : String | Nil = nil, add_bookmark = true)
final_pdf_file = chapter_file_name chapter_id, tmp_path
tmp_pdf_file = "#{final_pdf_file}.tmp"

View File

@ -47,6 +47,13 @@ module Muse::Dl
temp_stitched_file.delete if temp_stitched_file
puts "Saved final output to #{parser.output}"
# Cleanup the chapter files
if parser.cleanup
thing.chapters.each do |c|
Fetch.cleanup(parser.tmp, c[0])
end
end
end
end