mirror of
https://github.com/jupyter/notebook.git
synced 2025-01-18 11:55:46 +08:00
only check listdir on dirs
is_hidden is called with files, not just dirs
This commit is contained in:
parent
74be15ec19
commit
3e67d961c9
@ -102,11 +102,13 @@ def is_hidden(abs_path, abs_root=''):
|
||||
if any(part.startswith('.') for part in inside_root.split(os.sep)):
|
||||
return True
|
||||
|
||||
# check that path can be listed
|
||||
try:
|
||||
os.listdir(abs_path)
|
||||
except Exception:
|
||||
return True
|
||||
# check that dirs can be listed
|
||||
# may fail on Windows junctions or non-user-readable dirs
|
||||
if os.path.isdir(abs_path):
|
||||
try:
|
||||
os.listdir(abs_path)
|
||||
except OSError:
|
||||
return True
|
||||
|
||||
# check UF_HIDDEN on any location up to root
|
||||
path = abs_path
|
||||
@ -114,7 +116,7 @@ def is_hidden(abs_path, abs_root=''):
|
||||
try:
|
||||
# may fail on Windows junctions
|
||||
st = os.stat(path)
|
||||
except Exception:
|
||||
except OSError:
|
||||
return True
|
||||
if getattr(st, 'st_flags', 0) & UF_HIDDEN:
|
||||
return True
|
||||
|
Loading…
Reference in New Issue
Block a user