mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Fix #2915 (Stanza does not show newly added books until calibre-server is restarted)
This commit is contained in:
parent
d3ef167774
commit
2f3fbbc377
@ -439,6 +439,8 @@ class LibraryDatabase2(LibraryDatabase):
|
||||
self.count = self.data.count
|
||||
|
||||
self.refresh()
|
||||
self.last_update_check = self.last_modified()
|
||||
|
||||
|
||||
def get_property(idx, index_is_id=False, loc=-1):
|
||||
row = self.data._data[idx] if index_is_id else self.data[idx]
|
||||
@ -672,6 +674,11 @@ class LibraryDatabase2(LibraryDatabase):
|
||||
''' Return last modified time as a UTC datetime object'''
|
||||
return datetime.utcfromtimestamp(os.stat(self.dbpath).st_mtime)
|
||||
|
||||
def check_if_modified(self):
|
||||
if self.last_modified() > self.last_update_check:
|
||||
self.refresh()
|
||||
self.last_update_check = datetime.utcnow()
|
||||
|
||||
def path(self, index, index_is_id=False):
|
||||
'Return the relative path to the directory containing this books files as a unicode string.'
|
||||
row = self.data._data[index] if index_is_id else self.data[index]
|
||||
|
@ -45,6 +45,8 @@ def expose(func):
|
||||
|
||||
def do(self, *args, **kwargs):
|
||||
dict.update(cherrypy.response.headers, {'Server':self.server_name})
|
||||
if not self.embedded:
|
||||
self.db.check_if_modified()
|
||||
return func(self, *args, **kwargs)
|
||||
|
||||
return cherrypy.expose(do)
|
||||
@ -344,6 +346,7 @@ class LibraryServer(object):
|
||||
item
|
||||
break
|
||||
self.opts = opts
|
||||
self.embedded = embedded
|
||||
self.max_cover_width, self.max_cover_height = \
|
||||
map(int, self.opts.max_cover.split('x'))
|
||||
self.max_stanza_items = opts.max_opds_items
|
||||
|
Loading…
x
Reference in New Issue
Block a user