Commit c3903c7e authored by Julien Muchembled's avatar Julien Muchembled

fixup! download: clean-up, fix, optimization

To be squashed with commit 4ccb79e9.
parent 09701a6f
...@@ -40,7 +40,12 @@ import re ...@@ -40,7 +40,12 @@ import re
import shutil import shutil
import tempfile import tempfile
import zc.buildout import zc.buildout
try:
from os.path import samefile
except ImportError:
samefile = lambda f1, f2: False
from . import bytes2str, str2bytes from . import bytes2str, str2bytes
from .rmtree import rmtree
class netrc(netrc.netrc): class netrc(netrc.netrc):
...@@ -161,7 +166,15 @@ class Download(object): ...@@ -161,7 +166,15 @@ class Download(object):
self.logger.debug("Fallback to cache using %s", self.logger.debug("Fallback to cache using %s",
cached_path, exception=1) cached_path, exception=1)
else: else:
locate_at(path, cached_path) # update cache if not samefile(path, cached_path):
# update cache
try:
os.remove(cached_path)
except OSError as e:
if e.errno != errno.EISDIR:
raise
rmtree(cached_path)
locate_at(path, cached_path)
return path, is_temp return path, is_temp
else: else:
self.logger.debug('Cache miss; will cache %s as %s' % self.logger.debug('Cache miss; will cache %s as %s' %
......
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