Reset the file cache when starting the embedded server prevents the memory cache from going out of sync with the file system cache on server restart

This commit is contained in:
Kovid Goyal 2017-05-14 18:41:47 +05:30
parent 795cb3e8a8
commit abcf435b2b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 6 additions and 0 deletions

View File

@ -43,6 +43,10 @@ mtimes = {}
rename_counter = 0 rename_counter = 0
def reset_caches():
mtimes.clear()
def open_for_write(fname): def open_for_write(fname):
try: try:
return share_open(fname, 'w+b') return share_open(fname, 'w+b')

View File

@ -83,11 +83,13 @@ class Server(object):
def serve_forever(self): def serve_forever(self):
self.exception = None self.exception = None
from calibre.srv.content import reset_caches
if self.state_callback is not None: if self.state_callback is not None:
try: try:
self.state_callback(True) self.state_callback(True)
except Exception: except Exception:
pass pass
reset_caches() # we reset the cache as the server tdir has changed
try: try:
self.loop.serve_forever() self.loop.serve_forever()
except BaseException as e: except BaseException as e: