From 7972040d5dffebc1b57bd5c2d5e278684423609c Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Tue, 20 Jun 2023 10:42:05 -0400 Subject: [PATCH] Updated re-encryption to no longer use optimized_edit, as it is now redundant Former-commit-id: e7f60332c00e1ba6be5372035c88e1828738d319 Former-commit-id: 86d492d1e464db37fef35e5963a541d79a3e6d54 --- lib/stweak.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/stweak.py b/lib/stweak.py index b625975..1db7cfd 100644 --- a/lib/stweak.py +++ b/lib/stweak.py @@ -238,10 +238,10 @@ def refresh_encryption(): _directory = sshyp_data.get('SSHYNC', 'local_dir').rstrip('/') # warn the user of potential data loss and prompt to continue - _proceed = curses_radio(('yes', 'no'), "are you sure you wish to re-encrypt all entries with this key?" - "\n\n\n\n\nWARNING: proceeding with this action will remove/overwrite" - " any directories matching the following:" - f"\n\n{home}/.local/share/sshyp.old\n{home}/.local/share/sshyp.new\n\n") + _proceed = curses_radio(('yes', 'no'), "are you sure you wish to re-encrypt all entries?\n\n\n\n\nWARNING: " + "proceeding with this action will remove/overwrite any directories matching" + " the following:\n\n" + f"{home}/.local/share/sshyp.old\n{home}/.local/share/sshyp.new\n\n") if _proceed != 0: return 3 @@ -261,12 +261,12 @@ def refresh_encryption(): # decrypt, optimize, and re-encrypt each entry with the newly selected key if isdir(_directory): curses_terminate('\noptimizing and re-encrypting entries... please wait - do not terminate this process') + _gpg_id = sshyp_data.get('CLIENT-GENERAL', 'gpg_id') for _root, _dirs, _files in sorted(walk(_directory, topdown=True)): for _filename in _files: Path(_root.replace(_directory, _directory + '.new', 1)).mkdir(0o700, parents=True, exist_ok=True) - _new_lines = optimized_edit(decrypt(f"{_root}/{_filename[:-4]}"), None, -1) - encrypt(_new_lines, f"{_root.replace(_directory, _directory + '.new', 1)}/{_filename[:-4]}", - sshyp_data.get('CLIENT-GENERAL', 'gpg_id')) + encrypt(decrypt(f"{_root}/{_filename[:-4]}"), + f"{_root.replace(_directory, _directory + '.new', 1)}/{_filename[:-4]}", _gpg_id) # create a backup of the original version and activate the new version move(_directory, _directory + '.old')