Fix #2915 (Stanza does not show newly added books until calibre-server is restarted)

This commit is contained in:
Kovid Goyal 2009-10-30 14:37:52 -06:00
parent d3ef167774
commit 2f3fbbc377
2 changed files with 10 additions and 0 deletions

View File

@ -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]

View File

@ -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