mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Copy to library: Fix annotations not being copied. Fixes #1962365 [Highlights missing when copying to another library](https://bugs.launchpad.net/calibre/+bug/1962365)
This commit is contained in:
parent
aec6b7c174
commit
a772d45227
@ -59,6 +59,9 @@ def postprocess_copy(book_id, new_book_id, new_authors, db, newdb, identical_boo
|
||||
co = db.conversion_options(book_id)
|
||||
if co is not None:
|
||||
newdb.set_conversion_options({new_book_id:co})
|
||||
annots = db.all_annotations_for_book(book_id)
|
||||
if annots:
|
||||
newdb.restore_annotations(new_book_id, annots)
|
||||
if identical_books_data is not None and duplicate_action != 'add':
|
||||
newdb.update_data_for_find_identical_books(new_book_id, identical_books_data)
|
||||
|
||||
|
@ -308,9 +308,22 @@ class AddRemoveTest(BaseTest):
|
||||
def test_copy_to_library(self): # {{{
|
||||
from calibre.db.copy_to_library import copy_one_book
|
||||
from calibre.ebooks.metadata import authors_to_string
|
||||
from calibre.utils.date import utcnow, EPOCH
|
||||
src_db = self.init_cache()
|
||||
dest_db = self.init_cache(self.cloned_library)
|
||||
|
||||
def a(**kw):
|
||||
ts = utcnow()
|
||||
kw['timestamp'] = utcnow().isoformat()
|
||||
return kw, (ts - EPOCH).total_seconds()
|
||||
|
||||
annot_list = [
|
||||
a(type='bookmark', title='bookmark1 changed', seq=1),
|
||||
a(type='highlight', highlighted_text='text1', uuid='1', seq=2),
|
||||
a(type='highlight', highlighted_text='text2', uuid='2', seq=3, notes='notes2 some word changed again'),
|
||||
]
|
||||
src_db.set_annotations_for_book(1, 'FMT1', annot_list)
|
||||
|
||||
def make_rdata(book_id=1, new_book_id=None, action='add'):
|
||||
return {
|
||||
'title': src_db.field_for('title', book_id),
|
||||
@ -326,6 +339,7 @@ class AddRemoveTest(BaseTest):
|
||||
self.assertEqual(rdata, make_rdata(new_book_id=max(dest_db.all_book_ids())))
|
||||
compare_field('timestamp')
|
||||
compare_field('uuid', self.assertNotEqual)
|
||||
self.assertEqual(src_db.all_annotations_for_book(1), dest_db.all_annotations_for_book(max(dest_db.all_book_ids())))
|
||||
rdata = copy_one_book(1, src_db, dest_db, preserve_date=False, preserve_uuid=True)
|
||||
self.assertEqual(rdata, make_rdata(new_book_id=max(dest_db.all_book_ids())))
|
||||
compare_field('timestamp', self.assertNotEqual)
|
||||
|
Loading…
x
Reference in New Issue
Block a user