When setting cover from a PDF file and the user clicks cancel, do not delete the existing cover

This commit is contained in:
Kovid Goyal 2018-04-12 08:14:24 +05:30
parent e64afede00
commit bee21462e0
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -872,12 +872,15 @@ class EditMetadataAction(InterfaceAction):
'Cannot read cover as the %s file is missing from this book') % 'PDF', show=True)
from calibre.gui2.metadata.pdf_covers import PDFCovers
d = PDFCovers(pdfpath, parent=self.gui)
if d.exec_() == d.Accepted:
ret = d.exec_()
if ret == d.Accepted:
cpath = d.cover_path
if cpath:
with open(cpath, 'rb') as f:
cdata = f.read()
d.cleanup()
if ret != d.Accepted:
return
else:
stream = BytesIO()
try: