aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2013-10-09 10:21:52 +0200
committerMattias Andrée <maandree@operamail.com>2013-10-09 10:21:52 +0200
commitf2ef2a0738fe7563ca3328a8d32b954b27b48823 (patch)
tree730308b785dbcc31d9b08e70d6d7886b58154faa /src
parentadd bug todo (diff)
downloadbfind-f2ef2a0738fe7563ca3328a8d32b954b27b48823.tar.gz
bfind-f2ef2a0738fe7563ca3328a8d32b954b27b48823.tar.bz2
bfind-f2ef2a0738fe7563ca3328a8d32b954b27b48823.tar.xz
fix symlinking problems with xdev
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/bfind.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/bfind.py b/src/bfind.py
index abf7284..bf88d06 100755
--- a/src/bfind.py
+++ b/src/bfind.py
@@ -64,14 +64,20 @@ while len(queue) > 0:
if os.path.realpath(path) in visited_name:
continue
visited_name.add(os.path.realpath(path))
- if not xdev:
- if os.stat(path).st_dev != start_dev: # TODO make sure there is not symlinking problems # TODO fails on broken links
- continue
sys.stdout.buffer.write(path.encode('utf-8'))
sys.stdout.buffer.write(ending)
sys.stdout.buffer.flush()
+ if not xdev:
+ try:
+ if os.stat(path).st_dev != start_dev:
+ continue
+ except:
+ pass # link is broken
if os.path.isdir(path) and (symlinks or not os.path.islink(path)):
- for subd in os.listdir(path):
- subd = path + os.sep + subd
- queue.append(subd)
+ try:
+ for subd in os.listdir(path):
+ subd = path + os.sep + subd
+ queue.append(subd)
+ except PermissionError:
+ print('Permission denied: %s' % path)