|
31 | 31 | import jupyter_server
|
32 | 32 | from jupyter_server._tz import utcnow
|
33 | 33 | from jupyter_server.i18n import combine_translations
|
34 |
| -from jupyter_server.utils import is_hidden, url_path_join, url_is_absolute, url_escape |
| 34 | +from jupyter_server.utils import ensure_async, is_hidden, url_path_join, url_is_absolute, url_escape |
35 | 35 | from jupyter_server.services.security import csp_report_uri
|
36 | 36 |
|
37 | 37 | #-----------------------------------------------------------------------------
|
@@ -800,28 +800,28 @@ class FilesRedirectHandler(JupyterHandler):
|
800 | 800 | """Handler for redirecting relative URLs to the /files/ handler"""
|
801 | 801 |
|
802 | 802 | @staticmethod
|
803 |
| - def redirect_to_files(self, path): |
| 803 | + async def redirect_to_files(self, path): |
804 | 804 | """make redirect logic a reusable static method
|
805 | 805 |
|
806 | 806 | so it can be called from other handlers.
|
807 | 807 | """
|
808 | 808 | cm = self.contents_manager
|
809 |
| - if cm.dir_exists(path): |
| 809 | + if await ensure_async(cm.dir_exists(path)): |
810 | 810 | # it's a *directory*, redirect to /tree
|
811 | 811 | url = url_path_join(self.base_url, 'tree', url_escape(path))
|
812 | 812 | else:
|
813 | 813 | orig_path = path
|
814 | 814 | # otherwise, redirect to /files
|
815 | 815 | parts = path.split('/')
|
816 | 816 |
|
817 |
| - if not cm.file_exists(path=path) and 'files' in parts: |
| 817 | + if not await ensure_async(cm.file_exists(path=path)) and 'files' in parts: |
818 | 818 | # redirect without files/ iff it would 404
|
819 | 819 | # this preserves pre-2.0-style 'files/' links
|
820 | 820 | self.log.warning("Deprecated files/ URL: %s", orig_path)
|
821 | 821 | parts.remove('files')
|
822 | 822 | path = '/'.join(parts)
|
823 | 823 |
|
824 |
| - if not cm.file_exists(path=path): |
| 824 | + if not await ensure_async(cm.file_exists(path=path)): |
825 | 825 | raise web.HTTPError(404)
|
826 | 826 |
|
827 | 827 | url = url_path_join(self.base_url, 'files', url_escape(path))
|
|
0 commit comments