mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
cover_last_modified()
This commit is contained in:
parent
a65f804243
commit
a49b518cde
@ -963,6 +963,13 @@ class DB(object):
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
def cover_last_modified(self, path):
|
||||
path = os.path.abspath(os.path.join(self.library_path, path, 'cover.jpg'))
|
||||
try:
|
||||
return utcfromtimestamp(os.stat(path).st_mtime)
|
||||
except EnvironmentError:
|
||||
pass # Cover doesn't exist
|
||||
|
||||
def copy_cover_to(self, path, dest, windows_atomic_move=None, use_hardlink=False):
|
||||
path = os.path.abspath(os.path.join(self.library_path, path, 'cover.jpg'))
|
||||
if windows_atomic_move is not None:
|
||||
|
@ -526,6 +526,14 @@ class Cache(object):
|
||||
ret = i
|
||||
return ret
|
||||
|
||||
@read_api
|
||||
def cover_last_modified(self, book_id):
|
||||
try:
|
||||
path = self._field_for('path', book_id).replace('/', os.sep)
|
||||
except AttributeError:
|
||||
return
|
||||
return self.backend.cover_last_modified(path)
|
||||
|
||||
@read_api
|
||||
def copy_cover_to(self, book_id, dest, use_hardlink=False):
|
||||
'''
|
||||
|
@ -290,6 +290,10 @@ class LibraryDatabase(object):
|
||||
mi = self.new_api.get_metadata(book_id, get_cover=key == 'cover')
|
||||
return mi.get(key, default)
|
||||
|
||||
def cover_last_modified(self, index, index_is_id=False):
|
||||
book_id = index if index_is_id else self.id(index)
|
||||
return self.new_api.cover_last_modified(book_id) or self.last_modified()
|
||||
|
||||
def authors_sort_strings(self, index, index_is_id=False):
|
||||
book_id = index if index_is_id else self.id(index)
|
||||
return list(self.new_api.author_sort_strings_for_books((book_id,))[book_id])
|
||||
|
Loading…
x
Reference in New Issue
Block a user