Commit c3903c7e authored by Julien Muchembled's avatar Julien Muchembled

fixup! download: clean-up, fix, optimization

To be squashed with commit 4ccb79e9.
parent 09701a6f
Pipeline #19720 passed with stage
in 0 seconds
......@@ -40,7 +40,12 @@ import re
import shutil
import tempfile
import zc.buildout
try:
from os.path import samefile
except ImportError:
samefile = lambda f1, f2: False
from . import bytes2str, str2bytes
from .rmtree import rmtree
class netrc(netrc.netrc):
......@@ -161,7 +166,15 @@ class Download(object):
self.logger.debug("Fallback to cache using %s",
cached_path, exception=1)
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
else:
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