RepositoryCache: don't cache large objects

avoids excessive cache repository disk usage
This commit is contained in:
Marian Beermann 2016-05-20 02:01:07 +02:00
parent d043794757
commit f7f95ae731
No known key found for this signature in database
GPG Key ID: 9B8450B91D1362C1
1 changed files with 5 additions and 1 deletions

View File

@ -414,6 +414,9 @@ class RepositoryCache(RepositoryNoCache):
Caches Repository GET operations using a local temporary Repository.
"""
# maximum object size that will be cached, 64 kiB.
THRESHOLD = 2**16
def __init__(self, repository):
super().__init__(repository)
tmppath = tempfile.mkdtemp(prefix='borg-tmp')
@ -434,6 +437,7 @@ class RepositoryCache(RepositoryNoCache):
except Repository.ObjectNotFound:
for key_, data in repository_iterator:
if key_ == key:
if len(data) <= self.THRESHOLD:
self.caching_repo.put(key, data)
yield data
break