diff --git a/src/calibre/library/database2.py b/src/calibre/library/database2.py index cec88b6d5c..e30b11cb20 100644 --- a/src/calibre/library/database2.py +++ b/src/calibre/library/database2.py @@ -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] diff --git a/src/calibre/library/server.py b/src/calibre/library/server.py index fc855f35ce..15746cbc61 100644 --- a/src/calibre/library/server.py +++ b/src/calibre/library/server.py @@ -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