mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-01 14:47:17 -04:00
Optimized cross-device entry deletion code
Former-commit-id: 2a1dcda6460c06103846b41fbf2d83bf78c05527 [formerly f1aca39fd1]
Former-commit-id: 268b5564ff2f4cc157ebe039e9c46826a4bdb878
This commit is contained in:
+8
-14
@@ -423,22 +423,16 @@ def sync(): # calls sshync to sync changes to the user's server
|
|||||||
_deletion_database = None
|
_deletion_database = None
|
||||||
s_exit(1)
|
s_exit(1)
|
||||||
for _file in _deletion_database:
|
for _file in _deletion_database:
|
||||||
if _file[:-1].endswith('/'):
|
try:
|
||||||
try:
|
if silent_sync != 1:
|
||||||
if silent_sync != 1:
|
print(f"\u001b[38;5;208m{_file[:-1]}\u001b[0m has been sheared, removing...")
|
||||||
print(f"\u001b[38;5;208m{_file[:-1]}\u001b[0m has been sheared, removing...")
|
if _file[:-1].endswith('/'):
|
||||||
rmtree(f"{directory}{_file[:-1]}")
|
rmtree(f"{directory}{_file[:-1]}")
|
||||||
except FileNotFoundError:
|
else:
|
||||||
if silent_sync != 1:
|
|
||||||
print('folder does not exist locally.')
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
if silent_sync != 1:
|
|
||||||
print(f"\u001b[38;5;208m{_file[:-1]}\u001b[0m has been sheared, removing...")
|
|
||||||
remove(f"{directory}{_file[:-1]}.gpg")
|
remove(f"{directory}{_file[:-1]}.gpg")
|
||||||
except (FileNotFoundError, IsADirectoryError):
|
except FileNotFoundError:
|
||||||
if silent_sync != 1:
|
if silent_sync != 1:
|
||||||
print('file does not exist locally.')
|
print('location does not exist locally')
|
||||||
# check for new folders
|
# check for new folders
|
||||||
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {port} {username_ssh}@{ip} \"cd /bin; python -c "
|
system(f"ssh -i '{path.expanduser('~/.ssh/sshyp')}' -p {port} {username_ssh}@{ip} \"cd /bin; python -c "
|
||||||
f"'import sshypRemote; sshypRemote.folder_check()'\"")
|
f"'import sshypRemote; sshypRemote.folder_check()'\"")
|
||||||
|
|||||||
+5
-8
@@ -10,16 +10,13 @@ from shutil import rmtree
|
|||||||
# utility functions
|
# utility functions
|
||||||
|
|
||||||
def delete(_file_path): # deletes an entry or folder, should be run remotely via ssh
|
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}")
|
rmtree(f"{expanduser('~/.local/share/sshyp/')}{_file_path}")
|
||||||
except FileNotFoundError:
|
else:
|
||||||
print('folder does not exist remotely')
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
remove(f"{expanduser('~/.local/share/sshyp/')}{_file_path}.gpg")
|
remove(f"{expanduser('~/.local/share/sshyp/')}{_file_path}.gpg")
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print('file does not exist remotely')
|
print('location does not exist remotely')
|
||||||
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}", 'w')
|
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}^&*{_device_name}", 'w')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user