mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
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:
parent
795cb3e8a8
commit
abcf435b2b
@ -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')
|
||||||
|
@ -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:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user