mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-05 08:37:14 -04:00
Added folder deletion
This commit is contained in:
@@ -221,10 +221,16 @@ 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:
|
||||||
try:
|
if _file.endswith('/'):
|
||||||
remove(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}")
|
try:
|
||||||
except FileNotFoundError:
|
rmtree(f"{path.expanduser('~/.password-pasture/')}{_file[:-1]}")
|
||||||
print('\nFile does not exist locally.\n')
|
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
|
# set permissions before uploading
|
||||||
system('find ' + directory + ' -type d -exec chmod -R 700 {} +')
|
system('find ' + directory + ' -type d -exec chmod -R 700 {} +')
|
||||||
system('find ' + directory + ' -type f -exec chmod -R 600 {} +')
|
system('find ' + directory + ' -type f -exec chmod -R 600 {} +')
|
||||||
|
|||||||
+11
-4
@@ -4,15 +4,22 @@
|
|||||||
|
|
||||||
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):
|
||||||
try:
|
if _file_path.endswith('/'):
|
||||||
remove(f"{expanduser('~/.password-pasture/')}{_file_path}.gpg")
|
try:
|
||||||
except FileNotFoundError:
|
rmtree(f"{expanduser('~/.password-pasture/')}{_file_path}")
|
||||||
print('\nFile does not exist remotely.\n')
|
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')):
|
for _device_name in listdir(expanduser('~/.config/sshyp/devices')):
|
||||||
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}.{_device_name}.del", 'w')
|
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}.{_device_name}.del", 'w')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user