From bee21462e02d256240e20798f9da5c50d65dc5d9 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 12 Apr 2018 08:14:24 +0530 Subject: [PATCH] When setting cover from a PDF file and the user clicks cancel, do not delete the existing cover --- src/calibre/gui2/actions/edit_metadata.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/actions/edit_metadata.py b/src/calibre/gui2/actions/edit_metadata.py index 2835d96e0e..232bcb90fe 100644 --- a/src/calibre/gui2/actions/edit_metadata.py +++ b/src/calibre/gui2/actions/edit_metadata.py @@ -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: