mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-03 07:37:16 -04:00
Do not re-encrypt and sync if an edited note is unchanged
Former-commit-id: b8bcb481830ad5deb344d4d0c79976db7f06bb52 Former-commit-id: 6ebe9ee2f25dcfd90bea3784d337cb6cefbe903e
This commit is contained in:
+6
-3
@@ -117,14 +117,17 @@ def pass_gen():
|
|||||||
|
|
||||||
|
|
||||||
# creates a temporary file to allow notes to be edited by standard editors
|
# creates a temporary file to allow notes to be edited by standard editors
|
||||||
def edit_note(_note_lines):
|
def edit_note(_note_lines, _exit_on_match=False):
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
|
_joined_note_lines = '\n'.join(_note_lines)
|
||||||
with NamedTemporaryFile(mode='w+') as _tmp:
|
with NamedTemporaryFile(mode='w+') as _tmp:
|
||||||
_tmp.write('\n'.join(_note_lines))
|
_tmp.write(_joined_note_lines)
|
||||||
_tmp.seek(0)
|
_tmp.seek(0)
|
||||||
run((editor, _tmp.name))
|
run((editor, _tmp.name))
|
||||||
_tmp.seek(0)
|
_tmp.seek(0)
|
||||||
_new_note = _tmp.read().rstrip()
|
_new_note = _tmp.read().rstrip()
|
||||||
|
if _exit_on_match and _joined_note_lines == _new_note:
|
||||||
|
s_exit(0)
|
||||||
return _new_note
|
return _new_note
|
||||||
|
|
||||||
|
|
||||||
@@ -483,7 +486,7 @@ def edit():
|
|||||||
_detail, _edit_line = str(input('url: ')), 2
|
_detail, _edit_line = str(input('url: ')), 2
|
||||||
if arguments[2] in ('note', '-n'):
|
if arguments[2] in ('note', '-n'):
|
||||||
_old_lines = decrypt(directory + entry_name, _quick_verify=quick_unlock_enabled)
|
_old_lines = decrypt(directory + entry_name, _quick_verify=quick_unlock_enabled)
|
||||||
_new_lines = _old_lines[0:3] + edit_note(_old_lines[3:]).split('\n')
|
_new_lines = _old_lines[0:3] + edit_note(_old_lines[3:], True).split('\n')
|
||||||
else:
|
else:
|
||||||
_new_lines = optimized_edit(decrypt(directory + entry_name, _quick_verify=quick_unlock_enabled), _detail,
|
_new_lines = optimized_edit(decrypt(directory + entry_name, _quick_verify=quick_unlock_enabled), _detail,
|
||||||
_edit_line)
|
_edit_line)
|
||||||
|
|||||||
Reference in New Issue
Block a user