mirror of
https://github.com/jupyter/notebook.git
synced 2025-03-07 13:07:22 +08:00
fix test suite
is_hidden expects the file to actually exist, so I've rearranged the logic such that is_hidden is called only after it's clear that the file exists.
This commit is contained in:
parent
d6f2dfefea
commit
6c8cccf9e3
@ -180,9 +180,10 @@ class FileNotebookManager(NotebookManager):
|
|||||||
"""List the directories for a given API style path."""
|
"""List the directories for a given API style path."""
|
||||||
path = path.strip('/')
|
path = path.strip('/')
|
||||||
os_path = self._get_os_path('', path)
|
os_path = self._get_os_path('', path)
|
||||||
if is_hidden(os_path, self.notebook_dir):
|
if not os.path.isdir(os_path):
|
||||||
|
raise web.HTTPError(404, u'directory does not exist: %r' % os_path)
|
||||||
|
elif is_hidden(os_path, self.notebook_dir):
|
||||||
self.log.info("Refusing to serve hidden directory, via 404 Error")
|
self.log.info("Refusing to serve hidden directory, via 404 Error")
|
||||||
if not os.path.isdir(os_path) or is_hidden(os_path, self.notebook_dir):
|
|
||||||
raise web.HTTPError(404, u'directory does not exist: %r' % os_path)
|
raise web.HTTPError(404, u'directory does not exist: %r' % os_path)
|
||||||
dir_names = os.listdir(os_path)
|
dir_names = os.listdir(os_path)
|
||||||
dirs = []
|
dirs = []
|
||||||
|
@ -62,11 +62,12 @@ class TreeHandler(IPythonHandler):
|
|||||||
self.log.debug("Redirecting %s to %s", self.request.path, url)
|
self.log.debug("Redirecting %s to %s", self.request.path, url)
|
||||||
self.redirect(url)
|
self.redirect(url)
|
||||||
else:
|
else:
|
||||||
if nbm.is_hidden(path):
|
if not nbm.path_exists(path=path):
|
||||||
self.log.info("Refusing to serve hidden directory, via 404 Error")
|
|
||||||
if not nbm.path_exists(path=path) or nbm.is_hidden(path):
|
|
||||||
# Directory is hidden or does not exist.
|
# Directory is hidden or does not exist.
|
||||||
raise web.HTTPError(404)
|
raise web.HTTPError(404)
|
||||||
|
elif nbm.is_hidden(path):
|
||||||
|
self.log.info("Refusing to serve hidden directory, via 404 Error")
|
||||||
|
raise web.HTTPError(404)
|
||||||
breadcrumbs = self.generate_breadcrumbs(path)
|
breadcrumbs = self.generate_breadcrumbs(path)
|
||||||
page_title = self.generate_page_title(path)
|
page_title = self.generate_page_title(path)
|
||||||
self.write(self.render_template('tree.html',
|
self.write(self.render_template('tree.html',
|
||||||
|
Loading…
Reference in New Issue
Block a user