[Checkins] SVN: zc.buildout/branches/1.4/ in the download module, fixed the handling of directories that are pointed to by file-system paths and URLs

Thomas Lotze tl at gocept.com
Tue Dec 14 09:32:38 EST 2010


Log message for revision 118865:
  in the download module, fixed the handling of directories that are pointed to by file-system paths and URLs

Changed:
  U   zc.buildout/branches/1.4/buildout.cfg
  U   zc.buildout/branches/1.4/src/zc/buildout/download.py
  U   zc.buildout/branches/1.4/src/zc/buildout/download.txt

-=-
Modified: zc.buildout/branches/1.4/buildout.cfg
===================================================================
--- zc.buildout/branches/1.4/buildout.cfg	2010-12-14 14:13:14 UTC (rev 118864)
+++ zc.buildout/branches/1.4/buildout.cfg	2010-12-14 14:32:38 UTC (rev 118865)
@@ -1,7 +1,11 @@
 [buildout]
+extends = http://svn.zope.org/repos/main/zopetoolkit/branches/1.0/ztk.cfg
 develop = zc.recipe.egg_ .
 parts = test oltest py
 
+[versions]
+zc.buildout =
+
 [py]
 recipe = zc.recipe.egg
 eggs = zc.buildout

Modified: zc.buildout/branches/1.4/src/zc/buildout/download.py
===================================================================
--- zc.buildout/branches/1.4/src/zc/buildout/download.py	2010-12-14 14:13:14 UTC (rev 118864)
+++ zc.buildout/branches/1.4/src/zc/buildout/download.py	2010-12-14 14:32:38 UTC (rev 118865)
@@ -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:
@@ -244,8 +244,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/branches/1.4/src/zc/buildout/download.txt
===================================================================
--- zc.buildout/branches/1.4/src/zc/buildout/download.txt	2010-12-14 14:13:14 UTC (rev 118864)
+++ zc.buildout/branches/1.4/src/zc/buildout/download.txt	2010-12-14 14:32:38 UTC (rev 118865)
@@ -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