Transport: SshTransport bug in method rename #6725 solved #6750
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.
The comment in the code indicates a potential bug or misunderstanding around raising an OSError when newpath does not exist. The purpose of renaming is usually to move or rename a file or folder to a new location, so newpath doesn't need to exist. I think, the check might want to verify if newpath already exists to prevent overwriting existing files/folders unintentionally.
In my view it could be adjusted by raising an error if newpath exists rather than if it does not. A more appropriate exception might be FileExistsError.
The new code now checks if oldpath exists and raises an OSError if not.
Also the added check to ensure that newpath doesn't already exist (with using FileExistsError), to avoid unintentional overwriting.
Please let me know if its right,and I would really like to keep contributing more