Skip to content

Commit b79702c

Browse files
committed
updated error messages to not mention hidden files
1 parent cb3dc22 commit b79702c

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

notebook/services/contents/filemanager.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ def get(self, path, content=True, type=None, format=None):
437437
raise web.HTTPError(404, four_o_four)
438438

439439
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
440-
self.log.info("Refusing to serve hidden file or file in hidden directory %r, via 404 Error", os_path)
440+
self.log.info("Refusing to serve hidden file or directory %r, via 404 Error", os_path)
441441
raise web.HTTPError(404, four_o_four)
442442

443443

@@ -459,7 +459,7 @@ def get(self, path, content=True, type=None, format=None):
459459
def _save_directory(self, os_path, model, path=''):
460460
"""create a directory"""
461461
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
462-
raise web.HTTPError(400, f'Cannot create hidden directory {os_path!r}')
462+
raise web.HTTPError(400, f'Cannot create directory {os_path!r}')
463463
if not os.path.exists(os_path):
464464
with self.perm_to_403():
465465
os.mkdir(os_path)
@@ -480,7 +480,7 @@ def save(self, model, path=''):
480480
os_path = self._get_os_path(path)
481481

482482
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
483-
raise web.HTTPError(400, f'Cannot create hidden file or directory {os_path!r}')
483+
raise web.HTTPError(400, f'Cannot create file or directory {os_path!r}')
484484

485485
self.log.debug("Saving %s", os_path)
486486

@@ -532,7 +532,7 @@ def delete_file(self, path):
532532
raise web.HTTPError(404, four_o_four)
533533

534534
if is_hidden(os_path, self.root_dir) and not self.allow_hidden:
535-
raise web.HTTPError(400, f'Cannot delete hidden file or directory {os_path!r}')
535+
raise web.HTTPError(400, f'Cannot delete file or directory {os_path!r}')
536536

537537
def is_non_empty_dir(os_path):
538538
if os.path.isdir(os_path):
@@ -576,7 +576,7 @@ def rename_file(self, old_path, new_path):
576576
return
577577

578578
if (is_hidden(old_path, self.root_dir) or is_hidden(new_path, self.root_dir)) and not self.allow_hidden:
579-
raise web.HTTPError(400, f'Cannot rename hidden file or directory {os_path!r}')
579+
raise web.HTTPError(400, f'Cannot rename file or directory {os_path!r}')
580580

581581
# Perform path validation prior to converting to os-specific value since this
582582
# is still relative to root_dir.

notebook/services/contents/handlers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def patch(self, path=''):
129129
model = self.get_json_body()
130130
old_path = model.get('path')
131131
if old_path and (cm.is_hidden(path) or cm.is_hidden(old_path)) and not cm.allow_hidden:
132-
raise web.HTTPError(400, f'Cannot rename hidden file or directory {path!r}')
132+
raise web.HTTPError(400, f'Cannot rename file or directory {path!r}')
133133
if model is None:
134134
raise web.HTTPError(400, 'JSON body missing')
135135
model = yield maybe_future(cm.update(model, path))
@@ -200,7 +200,7 @@ def post(self, path=''):
200200
model = self.get_json_body()
201201
copy_from = model.get('copy_from')
202202
if copy_from and (cm.is_hidden(path) or cm.is_hidden(copy_from)) and not cm.allow_hidden:
203-
raise web.HTTPError(400, f'Cannot copy hidden file or directory {path!r}')
203+
raise web.HTTPError(400, f'Cannot copy file or directory {path!r}')
204204

205205
if model is not None:
206206
copy_from = model.get('copy_from')
@@ -232,7 +232,7 @@ def put(self, path=''):
232232
if model.get('copy_from'):
233233
raise web.HTTPError(400, "Cannot copy with PUT, only POST")
234234
if model.get('path') and (cm.is_hidden(path) or cm.is_hidden(model.get('path'))) and not cm.allow_hidden:
235-
raise web.HTTPError(400, f'Cannot create hidden file or directory {path!r}')
235+
raise web.HTTPError(400, f'Cannot create file or directory {path!r}')
236236
exists = yield maybe_future(self.contents_manager.file_exists(path))
237237
if exists:
238238
yield maybe_future(self._save(model, path))
@@ -248,7 +248,7 @@ def delete(self, path=''):
248248
cm = self.contents_manager
249249

250250
if cm.is_hidden(path) and not cm.allow_hidden:
251-
raise web.HTTPError(400, f'Cannot delete hidden file or directory {path!r}')
251+
raise web.HTTPError(400, f'Cannot delete file or directory {path!r}')
252252

253253
self.log.warning('delete %s', path)
254254
yield maybe_future(cm.delete(path))

0 commit comments

Comments
 (0)