Skip to content

Commit

Permalink
Some fixes to preferred_dir default handling
Browse files Browse the repository at this point in the history
  • Loading branch information
vidartf committed Oct 14, 2022
1 parent da33678 commit 760c90e
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions jupyter_server/services/contents/filemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,8 @@ def _default_preferred_dir(self):
DeprecationWarning,
stacklevel=3,
)
# For transitioning to relative path, we check if it is a valid relative path:
try:
if not os.path.isabs(value) and self.dir_exists(value):
return value
except HTTPError:
pass
value = self.parent._normalize_dir(value)
if not os.path.isdir(value):
raise TraitError(_i18n("No such directory: %r") % value)
raise TraitError(_i18n("No such preferred dir: %r") % value)
if not (value + os.path.sep).startswith(self.root_dir):
raise TraitError("%s is outside root contents directory" % value)
return os.path.relpath(value, self.root_dir).replace(os.path.sep, "/")
Expand All @@ -87,7 +80,7 @@ def _default_preferred_dir(self):
@validate("preferred_dir")
def _validate_preferred_dir(self, proposal):
try:
super()._validate_preferred_dir(proposal)
return super()._validate_preferred_dir(proposal)
except HTTPError as e:
raise TraitError(e.log_message) from e

Expand Down

0 comments on commit 760c90e

Please sign in to comment.