Don't serialize collection for etag

This commit is contained in:
Unrud 2017-07-22 21:25:28 +02:00 committed by Unrud
parent 95380c5ce7
commit debba3c7a1

View File

@ -445,7 +445,10 @@ class BaseCollection:
@property
def etag(self):
"""Encoded as quoted-string (see RFC 2616)."""
return get_etag(self.serialize())
etag = md5()
for item in self.get_all():
etag.update((item.href + "/" + item.etag).encode("utf-8"))
return '"%s"' % etag.hexdigest()
@classmethod
def create_collection(cls, href, collection=None, props=None):
@ -1328,10 +1331,7 @@ class Collection(BaseCollection):
def etag(self):
# reuse cached value if the storage is read-only
if self._writer or self._etag_cache is None:
etag = md5()
for item in self.get_all():
etag.update((item.href + "/" + item.etag).encode("utf-8"))
self._etag_cache = '"%s"' % etag.hexdigest()
self._etag_cache = super().etag
return self._etag_cache
_lock = threading.Lock()