From b14f925e53a0cf3f72236c62bc516a5da64d7562 Mon Sep 17 00:00:00 2001 From: Randall Winkhart Date: Mon, 15 May 2023 10:54:34 -0400 Subject: [PATCH] Do not delete existing device IDs until a new one is set Former-commit-id: 1f60a32e293d97059648c5c107af7e2b723f2319 Former-commit-id: 4c22d92687ccd58ddcf0cf55b0758e641b978ca4 --- lib/stweak.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/stweak.py b/lib/stweak.py index be3af5d..f918258 100644 --- a/lib/stweak.py +++ b/lib/stweak.py @@ -194,14 +194,15 @@ def ssh_config(): # device id configuration def dev_id_config(_ip, _username_ssh, _port): - for _id in listdir(f"{home}/.config/sshyp/devices"): - remove(f"{home}/.config/sshyp/devices/{_id}") _device_id_prefix = curses_text('name this device:\n\n\n\n\n(ctrl+g/enter to confirm)\n\n' 'important:\u001b[0m this id \u001b[4;1mmust\u001b[0m be ' 'unique amongst your client devices\n\nthis is used to keep ' 'track of database syncing and quick-unlock permissions\n') _device_id_suffix = string_gen('f', randint(24, 48)) _device_id = _device_id_prefix + '-' + _device_id_suffix + # remove existing device ids + for _id in listdir(f"{home}/.config/sshyp/devices"): + remove(f"{home}/.config/sshyp/devices/{_id}") open(f"{home}/.config/sshyp/devices/{_device_id}", 'w') # test server connection and attempt to register device id copy_id_check(_ip, _username_ssh, _port, _device_id, sshyp_data)