Merge pull request #1936 from pbiering/improve-mtime-size-cache
Improve mtime size cache for get request
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
* Extend: [logging] with profiling log per reqest or regular per request method
|
* Extend: [logging] with profiling log per reqest or regular per request method
|
||||||
* New: [logging] option to log response header on debug loglevel
|
* New: [logging] option to log response header on debug loglevel
|
||||||
* Adjust: [logging] header/content debug log indended by space to be skipped by logwatch
|
* Adjust: [logging] header/content debug log indended by space to be skipped by logwatch
|
||||||
|
* Improve: remove unnecessary open+read for mtime+size cache
|
||||||
|
|
||||||
## 3.5.9
|
## 3.5.9
|
||||||
* Extend: [auth] add support for type http_remote_user
|
* Extend: [auth] add support for type http_remote_user
|
||||||
|
|||||||
@@ -68,8 +68,21 @@ class CollectionPartGet(CollectionPartCache, CollectionPartLock,
|
|||||||
else:
|
else:
|
||||||
path = os.path.join(self._filesystem_path, href)
|
path = os.path.join(self._filesystem_path, href)
|
||||||
try:
|
try:
|
||||||
with open(path, "rb") as f:
|
if self._storage._use_mtime_and_size_for_item_cache is True:
|
||||||
raw_text = f.read()
|
# try to avoid "open"
|
||||||
|
if not os.path.isfile(path):
|
||||||
|
if not os.path.exists(path):
|
||||||
|
raise FileNotFoundError(path)
|
||||||
|
if os.path.isdir(path):
|
||||||
|
raise IsADirectoryError(path)
|
||||||
|
if not os.access(path, os.R_OK):
|
||||||
|
raise PermissionError(path)
|
||||||
|
else:
|
||||||
|
with open(path, "rb") as f:
|
||||||
|
# early read of the content
|
||||||
|
if self._storage._debug_cache_actions is True:
|
||||||
|
logger.debug("Item cache early read: %r", path)
|
||||||
|
raw_text = f.read()
|
||||||
except (FileNotFoundError, IsADirectoryError):
|
except (FileNotFoundError, IsADirectoryError):
|
||||||
return None
|
return None
|
||||||
except PermissionError:
|
except PermissionError:
|
||||||
@@ -100,6 +113,12 @@ class CollectionPartGet(CollectionPartCache, CollectionPartLock,
|
|||||||
# Check if another process created the file in the meantime
|
# Check if another process created the file in the meantime
|
||||||
cache_content = self._load_item_cache(href, cache_hash)
|
cache_content = self._load_item_cache(href, cache_hash)
|
||||||
if cache_content is None:
|
if cache_content is None:
|
||||||
|
if self._storage._use_mtime_and_size_for_item_cache is True:
|
||||||
|
# delayed read of the content
|
||||||
|
if self._storage._debug_cache_actions is True:
|
||||||
|
logger.debug("Item cache late read : %r", path)
|
||||||
|
with open(path, "rb") as f:
|
||||||
|
raw_text = f.read()
|
||||||
try:
|
try:
|
||||||
vobject_items = radicale_item.read_components(
|
vobject_items = radicale_item.read_components(
|
||||||
raw_text.decode(self._encoding))
|
raw_text.decode(self._encoding))
|
||||||
|
|||||||
Reference in New Issue
Block a user