-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove Redundant Dir_Exists Invocation When Creating New Files with ContentsManager #720
Merged
Zsailer
merged 12 commits into
jupyter-server:main
from
jhamet93:jhamet/Remove_Redundant_Invocations
Mar 29, 2022
+30
−6
Merged
Changes from 4 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e5d3921
Remove redundant calls in new_untitled method and added dir_exists ca…
42b87df
Remove dir_exists from Contents Manager handlers
2c86682
fix copy implementation
c8b4ea1
fix copy implementation
c9ba869
add back new line
a76c7f7
fix merge conflict
53992fb
remove duplication
jhamet93 becfda8
Merge branch 'main' of https://github.com/jupyter-server/jupyter_serv…
jhamet93 f6a300b
address feedback
jhamet93 cd96a4e
address feedback
jhamet93 073b46e
feedback
jhamet93 1e3b4b7
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably leverage the
self.dir_exists(to_path)
at L483 below to avoid a redundant dir-exists check.It's interesting, but the REST API appears to only support "copy" into a directory (typically the same directory as the source), whereas the ContentsManager also supports copy to a file, which is why the tests are failing (due to the first
dir_exists()
call sinceto_path
represents a file).It seems like the case that's missing here (even before this PR) is when
to_path
(being either a directory or file) references a non-existent directory. The way things stand now, this will result in a 500 error similar to the following (reproduced by changing a character in the parent directory name from'b'
to'x'
in thetest_copy
test):In order to preserve parity with the handler (where
to_path
can only be a directory and a 404 is returned if it doesn't exist), I think some additional logic is required to check ifto_path
is only a directory name or a combination of directory/file and ensure the respective directory portion exists (throwing 404 if it does not).(Same would be needed in the async CM as well.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good eye. Made the modifications and tried to preserve the parity you mentioned with a few test cases to verify.