Fix PackData._get_size().
authorJelmer Vernooij <jelmer@samba.org>
Fri, 12 Feb 2010 13:53:49 +0000 (14:53 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 12 Feb 2010 13:53:49 +0000 (14:53 +0100)
dulwich/pack.py

index 6d1a1752bc7c4e2b8b350de3e655253d7d484a2b..2695e3ddd1a4219bd18680741bc7ffae8aea95d5 100644 (file)
@@ -518,8 +518,11 @@ class PackData(object):
         self._file.close()
 
     def _get_size(self):
+        if self._size is not None:
+            return self._size
         self._size = os.path.getsize(self._filename)
         assert self._size >= self._header_size, "%s is too small for a packfile (%d < %d)" % (self._filename, self._size, self._header_size)
+        return self._size
   
     def _read_header(self):
         (version, self._num_objects) = read_pack_header(self._file)