From e9f1b2f726f8f656bc2ea3cc0126b875b77ea52f Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 8 Dec 2014 09:46:26 +0530 Subject: [PATCH] When doing "Add files to selected books" do not add the same format multiple times when the user selects multiple files of a particular format --- src/calibre/gui2/actions/add.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/calibre/gui2/actions/add.py b/src/calibre/gui2/actions/add.py index 18f0ed9668..fde60224de 100644 --- a/src/calibre/gui2/actions/add.py +++ b/src/calibre/gui2/actions/add.py @@ -132,9 +132,10 @@ class AddAction(InterfaceAction): if not confirm(msg, 'confirm_format_override_on_add', title=_('Are you sure?'), parent=self.gui): return + fmt_map = {os.path.splitext(fpath)[1][1:].upper():fpath for fpath in books} + for id_ in ids: - for fpath in books: - fmt = os.path.splitext(fpath)[1][1:].upper() + for fmt, fpath in fmt_map.iteritems(): if fmt: db.add_format_with_hooks(id_, fmt, fpath, index_is_id=True, notify=True)