From f44bd59b35015b7fc45cca0b18a5db41172801b2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 24 Nov 2010 10:28:36 -0700 Subject: [PATCH] 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 --- src/calibre/gui2/actions/convert.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/calibre/gui2/actions/convert.py b/src/calibre/gui2/actions/convert.py index 3828e9e1bf..821ebcd37f 100644 --- a/src/calibre/gui2/actions/convert.py +++ b/src/calibre/gui2/actions/convert.py @@ -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)