Commit 7adfcead authored by Jason R. Coombs's avatar Jason R. Coombs

Extract method to determine if a temporary file is current.

--HG--
branch : distribute
extra : rebase_source : ec2c1860f0ce9abbc3ea999aa54304ea9cc6ecd7
parent 9027ce54
......@@ -1422,11 +1422,8 @@ class ZipProvider(EggProvider):
self.egg_name, self._parts(zip_path)
)
if os.path.isfile(real_path):
stat = os.stat(real_path)
if stat.st_size==size and stat.st_mtime==timestamp:
# size and stamp match, don't bother extracting
return real_path
if self.is_current(real_path, zip_path):
return real_path
outf, tmpnam = _mkstemp(".$extract", dir=os.path.dirname(real_path))
os.write(outf, self.loader.get_data(zip_path))
......@@ -1439,11 +1436,9 @@ class ZipProvider(EggProvider):
except os.error:
if os.path.isfile(real_path):
stat = os.stat(real_path)
if stat.st_size==size and stat.st_mtime==timestamp:
# size and stamp match, somebody did it just ahead of
# us, so we're done
if self._is_current(real_path, zip_path):
# the file became current since it was checked above,
# so proceed.
return real_path
elif os.name=='nt': # Windows, del old file and retry
unlink(real_path)
......@@ -1456,6 +1451,16 @@ class ZipProvider(EggProvider):
return real_path
def _is_current(self, file_path, zip_path):
"""
Return True if the file_path is current for this zip_path
"""
timestamp, size = self._get_date_and_size(self.zipinfo[zip_path])
if not os.path.isfile(file_path):
return False
stat = os.stat(file_path)
return stat.st_size==size and stat.st_mtime==timestamp
def _get_eager_resources(self):
if self.eagers is None:
eagers = []
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment