From dca69aa470dd84d1967146e1f854b3313eb3a4a1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 9 Jul 2013 17:50:04 +0530 Subject: [PATCH] Confirm format override when add files to book When adding formats to an existing book, ask for confirmation if some formats will be overwritten. --- src/calibre/gui2/actions/add.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/calibre/gui2/actions/add.py b/src/calibre/gui2/actions/add.py index 4071ad1468..c5a778f965 100644 --- a/src/calibre/gui2/actions/add.py +++ b/src/calibre/gui2/actions/add.py @@ -110,6 +110,19 @@ class AddAction(InterfaceAction): return db = view.model().db + if len(ids) == 1: + formats = db.formats(ids[0], index_is_id=True) + if formats: + formats = {x.upper() for x in formats.split(',')} + nformats = {f.rpartition('.')[-1].upper() for f in books} + override = formats.intersection(nformats) + if override: + title = db.title(ids[0], index_is_id=True) + msg = _('The {0} format(s) will be replaced in the book {1}. Are you sure?').format( + ', '.join(override), title) + if not confirm(msg, 'confirm_format_override_on_add', title=_('Are you sure'), parent=self.gui): + return + for id_ in ids: for fpath in books: fmt = os.path.splitext(fpath)[1][1:].upper()