Prechádzať zdrojové kódy

use fstat if possible.

Jelmer Vernooij 15 rokov pred
rodič
commit
17063a6f5f
1 zmenil súbory, kde vykonal 3 pridanie a 2 odobranie
  1. 3 2
      dulwich/pack.py

+ 3 - 2
dulwich/pack.py

@@ -207,11 +207,12 @@ class PackIndex(object):
             self._file = file
         fileno = getattr(self._file, 'fileno', None)
         if fileno is not None:
+            fd = self._file.fileno()
             if size is None:
-                self._size = os.path.getsize(filename)
+                self._size = os.fstat(fd).st_size
             else:
                 self._size = size
-            self._contents = mmap.mmap(self._file.fileno(), self._size,
+            self._contents = mmap.mmap(fd, self._size,
                 access=mmap.ACCESS_READ)
         else:
             self._file.seek(0)