diff --git a/bin/sshyp b/bin/sshyp index 1f16267..b25f329 100755 --- a/bin/sshyp +++ b/bin/sshyp @@ -221,10 +221,16 @@ def sync(): # calls sshync to sync changes to the user's server _deletion_database = None s_exit() for _file in _deletion_database: - try: - remove(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}") - except FileNotFoundError: - print('\nFile does not exist locally.\n') + if _file.endswith('/'): + try: + rmtree(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}") + except FileNotFoundError: + print('\nFolder does not exist locally.\n') + else: + try: + remove(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}") + except FileNotFoundError: + print('\nFile does not exist locally.\n') # set permissions before uploading system('find ' + directory + ' -type d -exec chmod -R 700 {} +') system('find ' + directory + ' -type f -exec chmod -R 600 {} +') diff --git a/bin/sshyp-shear.py b/bin/sshyp-shear.py index e21330d..108a5cf 100755 --- a/bin/sshyp-shear.py +++ b/bin/sshyp-shear.py @@ -4,15 +4,22 @@ from os import remove, listdir from os.path import expanduser +from shutil import rmtree # utility functions def delete(_file_path): - try: - remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg") - except FileNotFoundError: - print('\nFile does not exist remotely.\n') + if _file_path.endswith('/'): + try: + rmtree(f"{expanduser('~/.password-pasture/')}{_file_path}") + except FileNotFoundError: + print('\nFolder does not exist remotely.') + else: + 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.replace('/', '@')}.{_device_name}.del", 'w')