From a67315d500eabdddd59a2228709cb7f6f35793bb Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 26 Jan 2016 19:44:30 +0100 Subject: [PATCH] use x-access for directory listing test in is_hidden listdir can be slow --- notebook/utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/notebook/utils.py b/notebook/utils.py index ee9c6aceb..44ea1f052 100644 --- a/notebook/utils.py +++ b/notebook/utils.py @@ -102,11 +102,13 @@ def is_hidden(abs_path, abs_root=''): return True # check that dirs can be listed - # may fail on Windows junctions or non-user-readable dirs if os.path.isdir(abs_path): + # use x-access, not actual listing, in case of slow/large listings try: - os.listdir(abs_path) + if not os.access(abs_path, os.X_OK): + return True except OSError: + # may fail on Windows junctions or non-user-readable dirs return True # check UF_HIDDEN on any location up to root