Added folder deletion

This commit is contained in:
2022-02-15 23:41:23 -05:00
parent 93ac4ef824
commit 0314bf36af
2 changed files with 21 additions and 8 deletions
+6
View File
@@ -221,6 +221,12 @@ def sync(): # calls sshync to sync changes to the user's server
_deletion_database = None _deletion_database = None
s_exit() s_exit()
for _file in _deletion_database: for _file in _deletion_database:
if _file.endswith('/'):
try:
rmtree(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}")
except FileNotFoundError:
print('\nFolder does not exist locally.\n')
else:
try: try:
remove(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}") remove(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}")
except FileNotFoundError: except FileNotFoundError:
+7
View File
@@ -4,11 +4,18 @@
from os import remove, listdir from os import remove, listdir
from os.path import expanduser from os.path import expanduser
from shutil import rmtree
# utility functions # utility functions
def delete(_file_path): def delete(_file_path):
if _file_path.endswith('/'):
try:
rmtree(f"{expanduser('~/.password-pasture/')}{_file_path}")
except FileNotFoundError:
print('\nFolder does not exist remotely.')
else:
try: try:
remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg") remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg")
except FileNotFoundError: except FileNotFoundError: