update_last_modified() and set_marked_ids()

This commit is contained in:
Kovid Goyal 2013-07-15 11:17:03 +05:30
parent 055bee6610
commit e8a912267d
2 changed files with 10 additions and 0 deletions

View File

@ -70,6 +70,7 @@ class LibraryDatabase(object):
self.last_update_check = self.last_modified() self.last_update_check = self.last_modified()
self.refresh_ids = self.data.refresh_ids self.refresh_ids = self.data.refresh_ids
self.set_marked_ids = self.data.set_marked_ids
self.is_case_sensitive = getattr(backend, 'is_case_sensitive', False) self.is_case_sensitive = getattr(backend, 'is_case_sensitive', False)
def close(self): def close(self):
@ -540,6 +541,10 @@ for field in (
return ret if field == 'languages' else retval return ret if field == 'languages' else retval
return func return func
setattr(LibraryDatabase, 'set_%s' % field.replace('!', ''), MT(setter(field))) setattr(LibraryDatabase, 'set_%s' % field.replace('!', ''), MT(setter(field)))
LibraryDatabase.update_last_modified = MT(
lambda self, book_ids, commit=False, now=None: self.new_api.update_last_modified(book_ids, now=now))
# }}} # }}}
# Legacy API to get information about many-(one, many) fields {{{ # Legacy API to get information about many-(one, many) fields {{{

View File

@ -416,6 +416,8 @@ class LegacyTest(BaseTest):
def test_legacy_setters(self): # {{{ def test_legacy_setters(self): # {{{
'Test methods that are directly equivalent in the old and new interface' 'Test methods that are directly equivalent in the old and new interface'
from calibre.ebooks.metadata.book.base import Metadata from calibre.ebooks.metadata.book.base import Metadata
from calibre.utils.date import now
n = now()
ndb = self.init_legacy(self.cloned_library) ndb = self.init_legacy(self.cloned_library)
db = self.init_old(self.cloned_library) db = self.init_old(self.cloned_library)
run_funcs(self, db, ndb, ( run_funcs(self, db, ndb, (
@ -437,6 +439,9 @@ class LegacyTest(BaseTest):
(db.clean,), (db.clean,),
('@all_tags',), ('@all_tags',),
('@tags', 0), ('@tags', 1), ('@tags', 2), ('@tags', 0), ('@tags', 1), ('@tags', 2),
('update_last_modified', (1,), True, n), ('update_last_modified', (3,), True, n),
('metadata_last_modified', 1, True), ('metadata_last_modified', 3, True),
)) ))
ndb = self.init_legacy(self.cloned_library) ndb = self.init_legacy(self.cloned_library)