Fix rename_file and delete_file to handle hidden files properly #1073
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.


In working on the Pull Request jupyter/notebook#6609 , I found that the tests for hidden files was broken, so that I fixed the tests and found more problems to fix.
Some mistakes regarding the tests are as follows (for example, see
test_400intests/services/contents/test_manager.pyhttps://github.com/jupyter-server/jupyter_server/blob/main/tests/services/contents/test_manager.py#L329-L342 ):try ... exceptinwith pytest.raises(HTTPError), but actually the exception is raised by thecm.newbefore thetryand never performs therename_file.old_pathornew_pathis set to the return value ofcm._get_os_path()(it seems an absolute path), but I assume thatrename_fileanddelete_fileexpects relative paths.When I fixed the test, I found the following new problems:
AsyncFileContentsManagerrename_fileanddelete_file, it is not checked if a path is a hidden file or not.FileContentsManagerdelete_file, the existence check has been made before determining whether the file is hidden.(This looks like the hidden check should be done first, as seen in rename_file).So I also fixed these problems.