-
Notifications
You must be signed in to change notification settings - Fork 84
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
[RHELC-1432] Copy instead of move when restoring a file #1122
Conversation
Moving a file back to its own directory is causing the file to lose the metadata and not letting the user enter in their system with SSH after the analysis is done. Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1122 +/- ##
=======================================
Coverage 95.30% 95.30%
=======================================
Files 51 51
Lines 4644 4645 +1
Branches 822 822
=======================================
+ Hits 4426 4427 +1
Misses 139 139
Partials 79 79
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
/packit test --labels tier0 |
@@ -120,7 +120,8 @@ def restore(self, rollback=True): | |||
return | |||
|
|||
try: | |||
shutil.move(self._backup_path, self.filepath) | |||
shutil.copy2(self._backup_path, self.filepath) | |||
os.remove(self._backup_path) |
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.
If there's an exception raised by the shutil.copy2
(for example the target directory doesn't exist), the os.remove
is not called.
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.
Yes, but that's how we should have it. If something didn't go well with the copy we don't want to remove the backup
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.
Looks good from QE POV.
Thank you for the fix @r0x0d !
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.
Since the behavior of move is copy and then remove the original file, the change does in fact the same.
Moving a file back to its own directory is causing the file to lose the metadata and not letting the user enter in their system with SSH after the analysis is done. Signed-off-by: Rodolfo Olivieri <rolivier@redhat.com>
Moving a file back to its own directory is causing the file to lose the metadata and not letting the user enter in their system with SSH after the analysis is done.
Jira Issues: RHELC-1432
Checklist
[RHELC-]
is part of the PR titleRelease Pending
if relevant