浏览代码

RepositoryCache: don't cache large objects

avoids excessive cache repository disk usage
Marian Beermann 9 年之前
父节点
当前提交
f7f95ae731
共有 1 个文件被更改,包括 5 次插入1 次删除
  1. 5 1
      borg/remote.py

+ 5 - 1
borg/remote.py

@@ -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,7 +437,8 @@ class RepositoryCache(RepositoryNoCache):
             except Repository.ObjectNotFound:
                 for key_, data in repository_iterator:
                     if key_ == key:
-                        self.caching_repo.put(key, data)
+                        if len(data) <= self.THRESHOLD:
+                            self.caching_repo.put(key, data)
                         yield data
                         break
         # Consume any pending requests