]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
'tahoe cp -r', upon encountering a dangling symlink, would assert out.
authorLarry Hosken <tahoe at lahosken.san-francisco.ca.us>
Thu, 8 Jan 2009 06:51:14 +0000 (23:51 -0700)
committerLarry Hosken <tahoe at lahosken.san-francisco.ca.us>
Thu, 8 Jan 2009 06:51:14 +0000 (23:51 -0700)
This was somewhat sad; the assertion didn't say what path caused the
error, what went wrong.  So... silently skip over things that are
neither dirs nor files.

src/allmydata/scripts/tahoe_cp.py
src/allmydata/test/test_cli.py

index 243fef8083eaccc0f5085aa0c9aea2933693113a..c98e665b5b8eb86184f3815fad30d82111e5edad 100644 (file)
@@ -117,9 +117,11 @@ class LocalDirectorySource:
                 self.children[n] = child
                 if recurse:
                     child.populate(True)
-            else:
-                assert os.path.isfile(pn)
+            elif os.path.isfile(pn):
                 self.children[n] = LocalFileSource(pn)
+            else:
+                # Could be dangling symlink; probably not copy-able.
+                pass
 
 class LocalDirectoryTarget:
     def __init__(self, progressfunc, pathname):
index e9071d0613cd8f11908f81630b7a27066c6b6cfb..5fd09b552df605194377e08daf192a9c7f35e06d 100644 (file)
@@ -600,3 +600,18 @@ class Cp(SystemTestMixin, CLITestMixin, unittest.TestCase):
 
         return d
     test_unicode_filename.todo = "This behavior is not yet supported, although it does happen to work (for reasons that are ill-understood) on many platforms.  See issue ticket #534."
+
+    def test_dangling_symlink_vs_recursion(self):
+        # cp -r on a directory containing a dangling symlink shouldn't assert
+        self.basedir = os.path.dirname(self.mktemp())
+        dn = os.path.join(self.basedir, "dir")
+        os.mkdir(dn)
+        fn = os.path.join(dn, "Fakebandica")
+        ln = os.path.join(dn, "link")
+        os.symlink(fn, ln)
+
+        d = self.set_up_nodes()
+        d.addCallback(lambda res: self.do_cli("create-alias", "tahoe"))
+        d.addCallback(lambda res: self.do_cli("cp", "--recursive",
+                                              dn, "tahoe:"))
+        return d