diff options
author | Lars Wirzenius <liw@liw.fi> | 2010-12-27 23:00:08 +0000 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2010-12-27 23:00:08 +0000 |
commit | c0cdc2ed795b839a599e1faa5172206ac79c7469 (patch) | |
tree | c173df5be400548c89c715e6bb4d59cdbb9d78b9 | |
parent | 7cb7ae85187c646868074f8ee465922812403c2c (diff) | |
download | obnam-c0cdc2ed795b839a599e1faa5172206ac79c7469.tar.gz |
Make depth_first not follow symlinks to dirs.
-rw-r--r-- | obnamlib/vfs.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/obnamlib/vfs.py b/obnamlib/vfs.py index 619c97f2..6933951d 100644 --- a/obnamlib/vfs.py +++ b/obnamlib/vfs.py @@ -17,6 +17,7 @@ import errno import os +import stat import urlparse import obnamlib @@ -196,7 +197,15 @@ class VirtualFileSystem(object): dirs = [] nondirs = [] for name in names: - if self.isdir(os.path.join(top, name)): + is_dir = False + try: + st = self.lstat(os.path.join(top, name)) + except OSError, e: + if e.errno != errno.ENOENT: + raise + else: + is_dir = stat.S_ISDIR(st.st_mode) + if is_dir: dirs.append(name) else: nondirs.append(name) @@ -524,6 +533,7 @@ class VfsTests(object): # pragma: no cover for dirname in self.dirs: self.fs.mkdir(dirname) self.dirs.insert(0, self.basepath) + self.fs.symlink('foo', 'symfoo') def test_depth_first_finds_all_dirs(self): self.set_up_depth_first() |