tahoe backup: skip all symlinks, with warning. Fixes #850, addresses #641.

This commit is contained in:
Brian Warner 2010-01-27 14:35:17 -08:00
parent 90828d40e7
commit e769bbb6dd
2 changed files with 9 additions and 4 deletions

View 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:

View 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