Adding books: When adding with auto-merge and auto-convert enabled, also run conversions for books into which the added files are merged. Fixes #1822018 [Does not auto-convert when adding existing book with overwrite selected](https://bugs.launchpad.net/calibre/+bug/1822018)

This commit is contained in:
Kovid Goyal 2019-03-28 14:38:50 +05:30
parent b0543d1bb5
commit 4ffffb143d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -89,6 +89,7 @@ class Adder(QObject):
self.report = [] self.report = []
self.items = [] self.items = []
self.added_book_ids = set() self.added_book_ids = set()
self.merged_formats_added_to = set()
self.merged_books = set() self.merged_books = set()
self.added_duplicate_info = set() self.added_duplicate_info = set()
self.pd.show() self.pd.show()
@ -383,6 +384,7 @@ class Adder(QObject):
ib_fmts = {fmt.upper() for fmt in self.db.formats(identical_book_id)} ib_fmts = {fmt.upper() for fmt in self.db.formats(identical_book_id)}
seen_fmts |= ib_fmts seen_fmts |= ib_fmts
self.add_formats(identical_book_id, paths, mi, replace=replace) self.add_formats(identical_book_id, paths, mi, replace=replace)
self.merged_formats_added_to.add(identical_book_id)
if gprefs['automerge'] == 'new record': if gprefs['automerge'] == 'new record':
incoming_fmts = {path.rpartition(os.extsep)[-1].upper() for path in paths} incoming_fmts = {path.rpartition(os.extsep)[-1].upper() for path in paths}
if incoming_fmts.intersection(seen_fmts): if incoming_fmts.intersection(seen_fmts):
@ -490,7 +492,7 @@ class Adder(QObject):
if gprefs['manual_add_auto_convert'] and self.added_book_ids and self.parent() is not None: if gprefs['manual_add_auto_convert'] and self.added_book_ids and self.parent() is not None:
self.parent().iactions['Convert Books'].auto_convert_auto_add( self.parent().iactions['Convert Books'].auto_convert_auto_add(
self.added_book_ids) self.added_book_ids | self.merged_formats_added_to)
try: try:
if callable(self.callback): if callable(self.callback):