Commit a6a5a021 authored by tlotze's avatar tlotze

ported bug fix about directory handling with download from 1.4 branch

git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@118894 62d5b8a3-27da-0310-9561-8e5933582275
parent 03c91c0a
...@@ -12,6 +12,11 @@ Change History ...@@ -12,6 +12,11 @@ Change History
due to missing support for the ``-E`` option, which only got added due to missing support for the ``-E`` option, which only got added
afterwards. afterwards.
Bugs fixed:
- In the download module, fixed the handling of directories that are pointed
to by file-system paths and ``file:`` URLs.
1.5.2 (2010-10-11) 1.5.2 (2010-10-11)
================== ==================
......
...@@ -118,7 +118,7 @@ class Download(object): ...@@ -118,7 +118,7 @@ class Download(object):
cached_path = os.path.join(cache_dir, cache_key) cached_path = os.path.join(cache_dir, cache_key)
self.logger.debug('Searching cache at %s' % cache_dir) self.logger.debug('Searching cache at %s' % cache_dir)
if os.path.isfile(cached_path): if os.path.exists(cached_path):
is_temp = False is_temp = False
if self.fallback: if self.fallback:
try: try:
...@@ -247,6 +247,9 @@ def locate_at(source, dest): ...@@ -247,6 +247,9 @@ def locate_at(source, dest):
if dest is None or realpath(dest) == realpath(source): if dest is None or realpath(dest) == realpath(source):
return source return source
if os.path.isdir(source):
shutil.copytree(source, dest)
else:
try: try:
os.link(source, dest) os.link(source, dest)
except (AttributeError, OSError): except (AttributeError, OSError):
......
...@@ -537,6 +537,25 @@ conversions: ...@@ -537,6 +537,25 @@ conversions:
>>> path, is_temp = Download()(server_url+'foo.txt', md5(text).hexdigest()) >>> path, is_temp = Download()(server_url+'foo.txt', md5(text).hexdigest())
>>> remove(path) >>> remove(path)
When "downloading" a directory given by file-system path or ``file:`` URL and
using a download cache at the same time, the cached directory wasn't handled
correctly. Consequently, the cache was defeated and an attempt to cache the
directory a second time broke. This is how it should work:
>>> download = Download(cache=cache)
>>> dirpath = join(server_data, 'some_directory')
>>> mkdir(dirpath)
>>> dest, _ = download(dirpath)
If we now modify the source tree, the second download will produce the
original one from the cache:
>>> mkdir(join(dirpath, 'foo'))
>>> ls(dirpath)
d foo
>>> dest, _ = download(dirpath)
>>> ls(dest)
Clean up Clean up
-------- --------
......
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