]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
tahoe backup: skip all symlinks, with warning. Fixes #850, addresses #641.
authorBrian Warner <warner@lothar.com>
Wed, 27 Jan 2010 22:35:17 +0000 (14:35 -0800)
committerBrian Warner <warner@lothar.com>
Wed, 27 Jan 2010 22:35:17 +0000 (14:35 -0800)
src/allmydata/scripts/tahoe_backup.py
src/allmydata/test/test_cli.py

index ee8cb56944d8c3acca685a073601d08270fe9695..f816eedde1554c5266b0e98a04a68d90d9394239 100644 (file)
@@ -171,14 +171,15 @@ class BackerUpper:
         for child in self.options.filter_listdir(children):
             childpath = os.path.join(localpath, child)
             child = unicode(child)
-            if os.path.isdir(childpath):
+            # note: symlinks to directories are both islink() and isdir()
+            if os.path.isdir(childpath) and not os.path.islink(childpath):
                 metadata = get_local_metadata(childpath)
                 # recurse on the child directory
                 childcap = self.process(childpath)
                 assert isinstance(childcap, str)
                 create_contents[child] = ("dirnode", childcap, metadata)
                 compare_contents[child] = childcap
-            elif os.path.isfile(childpath):
+            elif os.path.isfile(childpath) and not os.path.islink(childpath):
                 try:
                     childcap, metadata = self.upload(childpath)
                     assert isinstance(childcap, str)
@@ -189,7 +190,10 @@ class BackerUpper:
                     self.warn("WARNING: permission denied on file %s" % childpath)
             else:
                 self.files_skipped += 1
-                self.warn("WARNING: cannot backup special file %s" % childpath)
+                if os.path.islink(childpath):
+                    self.warn("WARNING: cannot backup symlink %s" % childpath)
+                else:
+                    self.warn("WARNING: cannot backup special file %s" % childpath)
 
         must_create, r = self.check_backupdb_directory(compare_contents)
         if must_create:
index dc45e2fe7ab8638c25f2569ff1397b7901deac1b..38ddbb69083a29adb32a8fcaa67605b497a96c54 100644 (file)
@@ -1383,7 +1383,8 @@ class Backup(GridTestMixin, CLITestMixin, StallMixin, unittest.TestCase):
 
         def _check((rc, out, err)):
             self.failUnlessEqual(rc, 2)
-            self.failUnlessEqual(err, "WARNING: cannot backup special file %s\n" % os.path.join(source, "foo2.txt"))
+            foo2 = os.path.join(source, "foo2.txt")
+            self.failUnlessEqual(err, "WARNING: cannot backup symlink %s\n" % foo2)
 
             fu, fr, fs, dc, dr, ds = self.count_output(out)
             # foo.txt