mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-08-30 05:46:31 -04:00
Replaced database downloads in sync() with newer output capture logic from sshync - much faster syncing
Former-commit-id: f6a9dce34263b3385440e6c166f9880f4781b5d5 [formerly 8276b9164e]
Former-commit-id: 850bf5889c2cf401ad9e91da5512a7455a353e6d
This commit is contained in:
+8
-10
@@ -4,7 +4,7 @@ from os.path import expanduser
|
||||
from shutil import rmtree
|
||||
|
||||
|
||||
def delete(_file_path, _target_database): # deletes an entry or folder, should be run remotely via ssh
|
||||
def delete(_file_path, _target_database): # deletes an entry or folder
|
||||
try:
|
||||
if _file_path.endswith('/'):
|
||||
rmtree(f"{expanduser('~/.local/share/sshyp/')}{_file_path}")
|
||||
@@ -12,26 +12,24 @@ def delete(_file_path, _target_database): # deletes an entry or folder, should
|
||||
remove(f"{expanduser('~/.local/share/sshyp/')}{_file_path}.gpg")
|
||||
except FileNotFoundError:
|
||||
print(f"location does not exist {_target_database}")
|
||||
for _device_name in listdir(expanduser('~/.config/sshyp/devices')):
|
||||
open(expanduser('~/.config/sshyp/deleted/') + _file_path.replace('/', '\x1e') + '\x1f' + _device_name, 'w')
|
||||
if _target_database == 'remotely':
|
||||
for _device_name in listdir(expanduser('~/.config/sshyp/devices')):
|
||||
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('')
|
||||
def deletion_check(_client_device_name): # creates a list of entries and folders to be deleted from a client device
|
||||
for _file in listdir(expanduser('~/.config/sshyp/deleted')):
|
||||
_file_path, _sep, _device = _file.partition('\x1f')
|
||||
_file_path = _file_path.replace('\x1e', '/')
|
||||
if _device == _client_device_name:
|
||||
print(_file_path)
|
||||
try:
|
||||
remove(f"{expanduser('~/.config/sshyp/deleted/')}{_file}")
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
open(expanduser('~/.config/sshyp/deletion_database'), 'a').write(_file_path + '\n')
|
||||
|
||||
|
||||
def folder_check(): # creates a list of folders to be compared with those of a local machine
|
||||
open(expanduser('~/.config/sshyp/folder_database'), 'w').write('')
|
||||
def folder_check(): # creates a list of folders to be compared with those of a client device
|
||||
for _root, _directories, _files in walk(expanduser('~/.local/share/sshyp')):
|
||||
for _dir in _directories:
|
||||
open(expanduser('~/.config/sshyp/folder_database'), 'a')\
|
||||
.write(f"{_root.replace(expanduser('~'), '')}/{_dir}\n")
|
||||
print(f"{_root.replace(expanduser('~'), '')}/{_dir}")
|
||||
|
||||
Reference in New Issue
Block a user