Optimized cross-device entry deletion code

Former-commit-id: 2a1dcda6460c06103846b41fbf2d83bf78c05527 [formerly f1aca39fd1]
Former-commit-id: 268b5564ff2f4cc157ebe039e9c46826a4bdb878
This commit is contained in:
2022-08-27 12:46:54 -04:00
parent 38c6ef3d1b
commit df1c6482a8
2 changed files with 13 additions and 22 deletions
+5 -8
View File
@@ -10,16 +10,13 @@ from shutil import rmtree
# utility functions
def delete(_file_path): # deletes an entry or folder, should be run remotely via ssh
if _file_path.endswith('/'):
try:
try:
if _file_path.endswith('/'):
rmtree(f"{expanduser('~/.local/share/sshyp/')}{_file_path}")
except FileNotFoundError:
print('folder does not exist remotely')
else:
try:
else:
remove(f"{expanduser('~/.local/share/sshyp/')}{_file_path}.gpg")
except FileNotFoundError:
print('file does not exist remotely')
except FileNotFoundError:
print('location does not exist remotely')
for _device_name in listdir(expanduser('~/.config/sshyp/devices')):
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}^&*{_device_name}", 'w')