Implemented multi-client deletion

This commit is contained in:
2022-02-02 09:23:43 -05:00
parent 3d7f08e43e
commit 7f00570249
2 changed files with 56 additions and 18 deletions
+19 -4
View File
@@ -8,8 +8,23 @@ from os.path import expanduser
# utility functions
def delete(_file_path, _client_device_name):
remove(f"{expanduser('~/.password-pasture/')}{_file_path}")
def delete(_file_path):
try:
remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg")
except FileNotFoundError:
print('\nFile does not exist remotely.\n')
for _device_name in listdir(expanduser('~/.config/sshyp/devices')):
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path}.{_device_name}.del", 'w')
remove(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path}.{_client_device_name}.del")
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}.{_device_name}.del", 'w')
def check(_client_device_name):
open(expanduser('~/.config/sshyp/deletion_database'), 'w').write('')
for _file in listdir(expanduser('~/.config/sshyp/deleted')):
_file_path = _file.replace('.gpg', '').replace('@', '/').split('.')[0]
_device = _file.replace('.gpg', '').split('.')[1]
if _device == _client_device_name:
try:
remove(f"{expanduser('~/.config/sshyp/deleted/')}{_file}")
except FileNotFoundError:
pass
open(expanduser('~/.config/sshyp/deletion_database'), 'a').write(_file_path + '.gpg\n')