updated error messages to not mention hidden files

This commit is contained in:
Ryan 2022-05-25 13:05:48 -04:00
parent cb3dc22f0f
commit b79702ccdb
2 changed files with 9 additions and 9 deletions

View File

@ -437,7 +437,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
raise web.HTTPError(404, four_o_four)
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
self.log.info("Refusing to serve hidden file or file in hidden directory %r, via 404 Error", os_path)
self.log.info("Refusing to serve hidden file or directory %r, via 404 Error", os_path)
raise web.HTTPError(404, four_o_four)
@ -459,7 +459,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
def _save_directory(self, os_path, model, path=''):
"""create a directory"""
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
raise web.HTTPError(400, f'Cannot create hidden directory {os_path!r}')
raise web.HTTPError(400, f'Cannot create directory {os_path!r}')
if not os.path.exists(os_path):
with self.perm_to_403():
os.mkdir(os_path)
@ -480,7 +480,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
os_path = self._get_os_path(path)
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
raise web.HTTPError(400, f'Cannot create hidden file or directory {os_path!r}')
raise web.HTTPError(400, f'Cannot create file or directory {os_path!r}')
self.log.debug("Saving %s", os_path)
@ -532,7 +532,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
raise web.HTTPError(404, four_o_four)
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
raise web.HTTPError(400, f'Cannot delete hidden file or directory {os_path!r}')
raise web.HTTPError(400, f'Cannot delete file or directory {os_path!r}')
def is_non_empty_dir(os_path):
if os.path.isdir(os_path):
@ -576,7 +576,7 @@ class FileContentsManager(FileManagerMixin, ContentsManager):
return
if (is_hidden(old_path, self.root_dir) or is_hidden(new_path, self.root_dir)) and not self.allow_hidden:
raise web.HTTPError(400, f'Cannot rename hidden file or directory {os_path!r}')
raise web.HTTPError(400, f'Cannot rename file or directory {os_path!r}')
# Perform path validation prior to converting to os-specific value since this
# is still relative to root_dir.

View File

@ -129,7 +129,7 @@ class ContentsHandler(APIHandler):
model = self.get_json_body()
old_path = model.get('path')
if old_path and (cm.is_hidden(path) or cm.is_hidden(old_path)) and not cm.allow_hidden:
raise web.HTTPError(400, f'Cannot rename hidden file or directory {path!r}')
raise web.HTTPError(400, f'Cannot rename file or directory {path!r}')
if model is None:
raise web.HTTPError(400, 'JSON body missing')
model = yield maybe_future(cm.update(model, path))
@ -200,7 +200,7 @@ class ContentsHandler(APIHandler):
model = self.get_json_body()
copy_from = model.get('copy_from')
if copy_from and (cm.is_hidden(path) or cm.is_hidden(copy_from)) and not cm.allow_hidden:
raise web.HTTPError(400, f'Cannot copy hidden file or directory {path!r}')
raise web.HTTPError(400, f'Cannot copy file or directory {path!r}')
if model is not None:
copy_from = model.get('copy_from')
@ -232,7 +232,7 @@ class ContentsHandler(APIHandler):
if model.get('copy_from'):
raise web.HTTPError(400, "Cannot copy with PUT, only POST")
if model.get('path') and (cm.is_hidden(path) or cm.is_hidden(model.get('path'))) and not cm.allow_hidden:
raise web.HTTPError(400, f'Cannot create hidden file or directory {path!r}')
raise web.HTTPError(400, f'Cannot create file or directory {path!r}')
exists = yield maybe_future(self.contents_manager.file_exists(path))
if exists:
yield maybe_future(self._save(model, path))
@ -248,7 +248,7 @@ class ContentsHandler(APIHandler):
cm = self.contents_manager
if cm.is_hidden(path) and not cm.allow_hidden:
raise web.HTTPError(400, f'Cannot delete hidden file or directory {path!r}')
raise web.HTTPError(400, f'Cannot delete file or directory {path!r}')
self.log.warning('delete %s', path)
yield maybe_future(cm.delete(path))