Skip to content

Refactor: Create backups of keys #108

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

Merged
merged 1 commit into from
Jun 16, 2025
Merged

Refactor: Create backups of keys #108

merged 1 commit into from
Jun 16, 2025

Conversation

OjusWiZard
Copy link
Member

Proposed changes

This is to make the keys safe, so that any possibility of corruption from the read operations can be dealt using the backups.

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Signed-off-by: Ojuswi Rastogi <ojuswimail@gmail.com>
migrated = False
backup_path = path.with_suffix(".bak")
if not backup_path.is_file():
shutil.copyfile(path, backup_path)
Copy link
Member Author

@OjusWiZard OjusWiZard Jun 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kalraash I Need a second opinion, that this method of copying file should not corrupt the original file, even if the process is killed in between, right?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks fine @OjusWiZard as shutil function never modifies or locks the original file. Even if the process is terminated mid-copy, only the destination file (backup_path) is at risk of being incomplete or corrupted.

@jmoreira-valory jmoreira-valory added the do not merge Do not merge this PR label Jun 8, 2025
@OjusWiZard OjusWiZard merged commit cea4f04 into main Jun 16, 2025
3 checks passed
@OjusWiZard OjusWiZard deleted the chore/backup-keys branch June 16, 2025 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Do not merge this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants