mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Book polishing: Fix bug that caused the ORIGINAL_EPUB format to be replaced by the EPUB format when polishing a book with both ORIGINA_EPUB and EPUB
This commit is contained in:
parent
68bbf64452
commit
32a6b097ef
@ -249,8 +249,10 @@ class Polish(QDialog): # {{{
|
|||||||
cover = os.path.join(base, 'cover.jpg')
|
cover = os.path.join(base, 'cover.jpg')
|
||||||
if db.copy_cover_to(book_id, cover, index_is_id=True):
|
if db.copy_cover_to(book_id, cover, index_is_id=True):
|
||||||
data['cover'] = cover
|
data['cover'] = cover
|
||||||
|
is_orig = {}
|
||||||
for fmt in formats:
|
for fmt in formats:
|
||||||
ext = fmt.replace('ORIGINAL_', '').lower()
|
ext = fmt.replace('ORIGINAL_', '').lower()
|
||||||
|
is_orig[ext.upper()] = 'ORIGINAL_' in fmt
|
||||||
with open(os.path.join(base, '%s.%s'%(book_id, ext)), 'wb') as f:
|
with open(os.path.join(base, '%s.%s'%(book_id, ext)), 'wb') as f:
|
||||||
db.copy_format_to(book_id, fmt, f, index_is_id=True)
|
db.copy_format_to(book_id, fmt, f, index_is_id=True)
|
||||||
data['files'].append(f.name)
|
data['files'].append(f.name)
|
||||||
@ -263,7 +265,7 @@ class Polish(QDialog): # {{{
|
|||||||
self.pd.set_msg(_('Queueing book %(nums)s of %(tot)s (%(title)s)')%dict(
|
self.pd.set_msg(_('Queueing book %(nums)s of %(tot)s (%(title)s)')%dict(
|
||||||
nums=num, tot=len(self.book_id_map), title=mi.title))
|
nums=num, tot=len(self.book_id_map), title=mi.title))
|
||||||
|
|
||||||
self.jobs.append((desc, data, book_id, base))
|
self.jobs.append((desc, data, book_id, base, is_orig))
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
class Report(QDialog): # {{{
|
class Report(QDialog): # {{{
|
||||||
@ -410,11 +412,11 @@ class PolishAction(InterfaceAction):
|
|||||||
d = Polish(self.gui.library_view.model().db, book_id_map, parent=self.gui)
|
d = Polish(self.gui.library_view.model().db, book_id_map, parent=self.gui)
|
||||||
if d.exec_() == d.Accepted and d.jobs:
|
if d.exec_() == d.Accepted and d.jobs:
|
||||||
show_reports = bool(d.show_reports.isChecked())
|
show_reports = bool(d.show_reports.isChecked())
|
||||||
for desc, data, book_id, base in reversed(d.jobs):
|
for desc, data, book_id, base, is_orig in reversed(d.jobs):
|
||||||
job = self.gui.job_manager.run_job(
|
job = self.gui.job_manager.run_job(
|
||||||
Dispatcher(self.book_polished), 'gui_polish', args=(data,),
|
Dispatcher(self.book_polished), 'gui_polish', args=(data,),
|
||||||
description=desc)
|
description=desc)
|
||||||
job.polish_args = (book_id, base, data['files'], show_reports)
|
job.polish_args = (book_id, base, data['files'], show_reports, is_orig)
|
||||||
if d.jobs:
|
if d.jobs:
|
||||||
self.gui.jobs_pointer.start()
|
self.gui.jobs_pointer.start()
|
||||||
self.gui.status_bar.show_message(
|
self.gui.status_bar.show_message(
|
||||||
@ -425,11 +427,11 @@ class PolishAction(InterfaceAction):
|
|||||||
self.gui.job_exception(job)
|
self.gui.job_exception(job)
|
||||||
return
|
return
|
||||||
db = self.gui.current_db
|
db = self.gui.current_db
|
||||||
book_id, base, files, show_reports = job.polish_args
|
book_id, base, files, show_reports, is_orig = job.polish_args
|
||||||
fmts = set()
|
fmts = set()
|
||||||
for path in files:
|
for path in files:
|
||||||
fmt = path.rpartition('.')[-1].upper()
|
fmt = path.rpartition('.')[-1].upper()
|
||||||
if tweaks['save_original_format_when_polishing']:
|
if tweaks['save_original_format_when_polishing'] and not is_orig[fmt]:
|
||||||
fmts.add(fmt)
|
fmts.add(fmt)
|
||||||
db.save_original_format(book_id, fmt, notify=False)
|
db.save_original_format(book_id, fmt, notify=False)
|
||||||
with open(path, 'rb') as f:
|
with open(path, 'rb') as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user