diff options
author | Mattias Andrée <maandree@operamail.com> | 2013-10-09 10:21:52 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@operamail.com> | 2013-10-09 10:21:52 +0200 |
commit | f2ef2a0738fe7563ca3328a8d32b954b27b48823 (patch) | |
tree | 730308b785dbcc31d9b08e70d6d7886b58154faa | |
parent | add bug todo (diff) | |
download | bfind-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 '')
-rwxr-xr-x | src/bfind.py | 18 |
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) |