return entry
-def find_random_files():
+def find_random_files(min_file_size=100):
""" generator over random file names
Checks if files are readable by user (os.access) and excludes dirs with
most volatile files and mounts; will still yield links or -- with a small
probablility -- names of dirs with many parents (no '/usr' but maybe
/usr/local/lib/python/site-packages/deltatar)
+
+ :param int min_file_size: size (in bytes) that returned files have to have
+ at least
"""
# prepare list of dirs in START_DIR that are not EXCLUDE_DIRS
if not os.access(next_result, os.R_OK):
#print('cannot access {}, try next'.format(next_result))
continue
- mode = os.stat(next_result).st_mode
+ statres = os.lstat(next_result)
+ if statres.st_size < min_file_size:
+ #print('file {} too small'.format(next_result))
+ continue
+ mode = statres.st_mode
if not any(mode_test(mode) for mode_test in OK_MODES):
#print('mode not accepted for {}, try next'.format(next_result))
continue