From f2ef2a0738fe7563ca3328a8d32b954b27b48823 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 9 Oct 2013 10:21:52 +0200 Subject: fix symlinking problems with xdev MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/bfind.py | 18 ++++++++++++------ 1 file 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) -- cgit v1.2.3-70-g09d2