-
Notifications
You must be signed in to change notification settings - Fork 24
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
fix: os.rename -> shutil.move #534
Conversation
01bef09
to
df3a31b
Compare
Replace instances of `os.rename` with `shutil.move` to handle the possibility of the destination being a different filesystem. If the source and destination are on the same filesystem, `os.rename` is used per https://docs.python.org/3.11/library/shutil.html#shutil.move Signed-off-by: Weston Steimel <commits@weston.slmail.me>
df3a31b
to
8683e67
Compare
As opposed to rename, when moving a dir to a dir, shutil.move will try to nest src under dst. Signed-off-by: Will Murphy <will.murphy@anchore.com>
src/vunnel/workspace.py
Outdated
@@ -243,17 +244,17 @@ def overlay_existing(self, source: str, move: bool = False) -> None: | |||
os.makedirs(os.path.dirname(dst), exist_ok=True) | |||
|
|||
if move: | |||
os.rename(src, dst) | |||
shutil.move(src, dst) |
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.
Actually, we might need the same change here, and it's just not failing a test.
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.
Is overlay_existing
actually used anywhere? I can't find any invocations of it. Maybe we can just remove it?
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.
I don't see it used anywhere. I think it was added by mistake in #520, since that PR went through a lot of iterations.
I've pushed a commit removing the function.
Signed-off-by: Will Murphy <will.murphy@anchore.com>
Replace instances of
os.rename
withshutil.move
to handle the possibility of the destination being a different filesystem. If the source and destination are on the same filesystem,os.rename
is used per https://docs.python.org/3.11/library/shutil.html#shutil.move