-
Notifications
You must be signed in to change notification settings - Fork 200
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
Solving bug in rename function #6735
base: main
Are you sure you want to change the base?
Changes from 2 commits
cfd8b31
790204e
d4b2b4d
a826a4c
484a9f7
051ef84
2023dbe
e2c34db
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1375,9 +1375,9 @@ def rename(self, oldpath: TransportPath, newpath: TransportPath): | |
# why to raise an OSError if the newpath does not exist? | ||
# ofcourse newpath shouldn't exist, that's why we are renaming it! | ||
# issue opened here: https://github.com/aiidateam/aiida-core/issues/6725 | ||
if not self.isfile(newpath): | ||
if not self.isdir(newpath): | ||
raise OSError(f'Destination {newpath} does not exist') | ||
|
||
if self.isfile(newpath) or self.isdir(newpath): | ||
raise OSError(f'Destination {newpath} already exist') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The docstring on line 1360 needs fixing. (github does not allow me to comment on that line) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the docstring on line 1360, it states that OSError is used for both cases—when oldpath and newpath both are not found—which needs to be fixed. However, is it okay to use specific errors (FileNotFoundError and FileExistsError) instead of OSError? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In general. you are right However, please note
For the sake of consistency --I assume-- |
||
|
||
return self.sftp.rename(oldpath, newpath) | ||
|
||
|
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.
maybe this is easier, and perhaps more readable.
Also I'm not entirely sure, if existing symlinks would get caught by
self.isfile
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.
Please also get rid of the comments above, line 1374-1377