Check to see that the result file from a conversion is not empty before adding it, protects against the case where the conversion process crashes and the GUI adds a zero byte file to the book record

This commit is contained in:
Kovid Goyal 2010-11-24 10:28:36 -07:00
parent a67f9a4e2b
commit f44bd59b35

View File

@ -165,6 +165,11 @@ class ConvertAction(InterfaceAction):
if job.failed:
self.gui.job_exception(job)
return
fmtf = temp_files[-1].name
if os.stat(fmtf).st_size < 1:
raise Exception(_('Empty output file, '
'probably the conversion process crashed'))
data = open(temp_files[-1].name, 'rb')
self.gui.library_view.model().db.add_format(book_id, \
fmt, data, index_is_id=True)