Update easy_sync.py
Browse files- easy_sync.py +3 -2
easy_sync.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
| 1 |
import subprocess, time, threading
|
| 2 |
|
| 3 |
class SyncingDirectory:
|
| 4 |
-
def __init__(self,source,destination,sync_deletions=False):
|
| 5 |
self.source = source
|
| 6 |
self.destination = destination
|
| 7 |
self.stop = threading.Event()
|
| 8 |
self.syncing_thread = threading.Thread(target=self._sync,args=(),daemon=True)
|
| 9 |
self.sync_deletions = sync_deletions
|
|
|
|
| 10 |
|
| 11 |
def _sync(self):
|
| 12 |
if self.sync_deletions:
|
|
@@ -15,7 +16,7 @@ class SyncingDirectory:
|
|
| 15 |
command = ['rsync','-aP',f'{self.source}/',f'{self.destination}']
|
| 16 |
while not self.stop.is_set():
|
| 17 |
subprocess.run(command)
|
| 18 |
-
time.sleep(
|
| 19 |
|
| 20 |
def quick_sync(self):
|
| 21 |
if self.sync_deletions:
|
|
|
|
| 1 |
import subprocess, time, threading
|
| 2 |
|
| 3 |
class SyncingDirectory:
|
| 4 |
+
def __init__(self,source,destination,sync_deletions=False,sync_time=60):
|
| 5 |
self.source = source
|
| 6 |
self.destination = destination
|
| 7 |
self.stop = threading.Event()
|
| 8 |
self.syncing_thread = threading.Thread(target=self._sync,args=(),daemon=True)
|
| 9 |
self.sync_deletions = sync_deletions
|
| 10 |
+
self.sync_time = sync_time
|
| 11 |
|
| 12 |
def _sync(self):
|
| 13 |
if self.sync_deletions:
|
|
|
|
| 16 |
command = ['rsync','-aP',f'{self.source}/',f'{self.destination}']
|
| 17 |
while not self.stop.is_set():
|
| 18 |
subprocess.run(command)
|
| 19 |
+
time.sleep(self.sync_time)
|
| 20 |
|
| 21 |
def quick_sync(self):
|
| 22 |
if self.sync_deletions:
|