[Checkins] SVN: zc.buildout/trunk/ ported bug fix about directory handling with download from 1.4 branch

Thomas Lotze tl at gocept.com
Wed Dec 15 01:49:42 EST 2010


Log message for revision 118894:
  ported bug fix about directory handling with download from 1.4 branch

Changed:
  U   zc.buildout/trunk/CHANGES.txt
  U   zc.buildout/trunk/src/zc/buildout/download.py
  U   zc.buildout/trunk/src/zc/buildout/download.txt

-=-
Modified: zc.buildout/trunk/CHANGES.txt
===================================================================
--- zc.buildout/trunk/CHANGES.txt	2010-12-15 06:38:44 UTC (rev 118893)
+++ zc.buildout/trunk/CHANGES.txt	2010-12-15 06:49:42 UTC (rev 118894)
@@ -12,6 +12,11 @@
   due to missing support for the ``-E`` option, which only got added
   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)
 ==================
 

Modified: zc.buildout/trunk/src/zc/buildout/download.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/download.py	2010-12-15 06:38:44 UTC (rev 118893)
+++ zc.buildout/trunk/src/zc/buildout/download.py	2010-12-15 06:49:42 UTC (rev 118894)
@@ -118,7 +118,7 @@
         cached_path = os.path.join(cache_dir, cache_key)
 
         self.logger.debug('Searching cache at %s' % cache_dir)
-        if os.path.isfile(cached_path):
+        if os.path.exists(cached_path):
             is_temp = False
             if self.fallback:
                 try:
@@ -247,8 +247,11 @@
     if dest is None or realpath(dest) == realpath(source):
         return source
 
-    try:
-        os.link(source, dest)
-    except (AttributeError, OSError):
-        shutil.copyfile(source, dest)
+    if os.path.isdir(source):
+        shutil.copytree(source, dest)
+    else:
+        try:
+            os.link(source, dest)
+        except (AttributeError, OSError):
+            shutil.copyfile(source, dest)
     return dest

Modified: zc.buildout/trunk/src/zc/buildout/download.txt
===================================================================
--- zc.buildout/trunk/src/zc/buildout/download.txt	2010-12-15 06:38:44 UTC (rev 118893)
+++ zc.buildout/trunk/src/zc/buildout/download.txt	2010-12-15 06:49:42 UTC (rev 118894)
@@ -537,7 +537,26 @@
 >>> path, is_temp = Download()(server_url+'foo.txt', md5(text).hexdigest())
 >>> 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
 --------
 



More information about the checkins mailing list