Ver Fonte

Use SpooledTemporaryFile rather than reading into memory.

Jelmer Vernooij há 2 anos atrás
pai
commit
3a74979aa6
1 ficheiros alterados com 4 adições e 2 exclusões
  1. 4 2
      dulwich/client.py

+ 4 - 2
dulwich/client.py

@@ -680,15 +680,17 @@ class GitClient(object):
         if CAPABILITY_THIN_PACK in self._fetch_capabilities:
             # TODO(jelmer): Avoid reading entire file into memory and
             # only processing it after the whole file has been fetched.
-            f = BytesIO()
+            from tempfile import SpooledTemporaryFile
+            f = SpooledTemporaryFile()
 
             def commit():
                 if f.tell():
                     f.seek(0)
                     target.object_store.add_thin_pack(f.read, None)
+                f.close()
 
             def abort():
-                pass
+                f.close()
 
         else:
             f, commit, abort = target.object_store.add_pack()