Use ASCII 30 and 31 as separators, removes limitations on "@", "^&*", and "*&^".

Former-commit-id: cd08e1adde9f810e0099338722b617357055c422 [formerly 289d12f45a]
Former-commit-id: 7f70d015e3afe2101aba2d1d21001101db0de81e
This commit is contained in:
2022-11-25 12:00:51 -05:00
parent 176ee623cf
commit 3392e3ceea
4 changed files with 5 additions and 23 deletions
+3 -8
View File
@@ -1,14 +1,9 @@
#!/usr/bin/env python3
# external modules
from os import listdir, remove, walk
from os.path import expanduser
from shutil import rmtree
# utility functions
def delete(_file_path, _target_database): # deletes an entry or folder, should be run remotely via ssh
try:
if _file_path.endswith('/'):
@@ -18,14 +13,14 @@ def delete(_file_path, _target_database): # deletes an entry or folder, should
except FileNotFoundError:
print(f"location does not exist {_target_database}")
for _device_name in listdir(expanduser('~/.config/sshyp/devices')):
open(f"{expanduser('~/.config/sshyp/deleted/')}{_file_path.replace('/', '@')}^&*{_device_name}", 'w')
open(expanduser('~/.config/sshyp/deleted/') + _file_path.replace('/', '\x1e') + '\x1f' + _device_name, 'w')
def deletion_check(_client_device_name): # creates a list of entries and folders to be deleted from a local machine
open(expanduser('~/.config/sshyp/deletion_database'), 'w').write('')
for _file in listdir(expanduser('~/.config/sshyp/deleted')):
_file_path = _file.replace('@', '/').split('^&*')[0]
_device = _file.split('^&*')[1]
_file_path, _sep, _device = _file.partition('\x1f')
_file_path = _file_path.replace('\x1e', '/')
if _device == _client_device_name:
try:
remove(f"{expanduser('~/.config/sshyp/deleted/')}{_file}")