mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 08:37:14 -04:00
Updated re-encryption to no longer use optimized_edit, as it is now redundant
Former-commit-id: e7f60332c00e1ba6be5372035c88e1828738d319 Former-commit-id: 86d492d1e464db37fef35e5963a541d79a3e6d54
This commit is contained in:
+7
-7
@@ -238,10 +238,10 @@ def refresh_encryption():
|
|||||||
_directory = sshyp_data.get('SSHYNC', 'local_dir').rstrip('/')
|
_directory = sshyp_data.get('SSHYNC', 'local_dir').rstrip('/')
|
||||||
|
|
||||||
# warn the user of potential data loss and prompt to continue
|
# 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?"
|
_proceed = curses_radio(('yes', 'no'), "are you sure you wish to re-encrypt all entries?\n\n\n\n\nWARNING: "
|
||||||
"\n\n\n\n\nWARNING: proceeding with this action will remove/overwrite"
|
"proceeding with this action will remove/overwrite any directories matching"
|
||||||
" any directories matching the following:"
|
" the following:\n\n"
|
||||||
f"\n\n{home}/.local/share/sshyp.old\n{home}/.local/share/sshyp.new\n\n")
|
f"{home}/.local/share/sshyp.old\n{home}/.local/share/sshyp.new\n\n")
|
||||||
if _proceed != 0:
|
if _proceed != 0:
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
@@ -261,12 +261,12 @@ def refresh_encryption():
|
|||||||
# decrypt, optimize, and re-encrypt each entry with the newly selected key
|
# decrypt, optimize, and re-encrypt each entry with the newly selected key
|
||||||
if isdir(_directory):
|
if isdir(_directory):
|
||||||
curses_terminate('\noptimizing and re-encrypting entries... please wait - do not terminate this process')
|
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 _root, _dirs, _files in sorted(walk(_directory, topdown=True)):
|
||||||
for _filename in _files:
|
for _filename in _files:
|
||||||
Path(_root.replace(_directory, _directory + '.new', 1)).mkdir(0o700, parents=True, exist_ok=True)
|
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(decrypt(f"{_root}/{_filename[:-4]}"),
|
||||||
encrypt(_new_lines, f"{_root.replace(_directory, _directory + '.new', 1)}/{_filename[:-4]}",
|
f"{_root.replace(_directory, _directory + '.new', 1)}/{_filename[:-4]}", _gpg_id)
|
||||||
sshyp_data.get('CLIENT-GENERAL', 'gpg_id'))
|
|
||||||
|
|
||||||
# create a backup of the original version and activate the new version
|
# create a backup of the original version and activate the new version
|
||||||
move(_directory, _directory + '.old')
|
move(_directory, _directory + '.old')
|
||||||
|
|||||||
Reference in New Issue
Block a user