feat: Upload-Thread-Management verbessert und Versionsnummer auf 1.0.40 erhöht
This commit is contained in:
9
app.py
9
app.py
@@ -589,6 +589,7 @@ def do_copy(src_devs, dst_dev, cfg):
|
|||||||
dst_mp = None
|
dst_mp = None
|
||||||
dst_owned = False
|
dst_owned = False
|
||||||
src_mounts = [] # [(src_dev, src_mp, src_owned)]
|
src_mounts = [] # [(src_dev, src_mp, src_owned)]
|
||||||
|
_upload_thread = None
|
||||||
try:
|
try:
|
||||||
with copy_lock:
|
with copy_lock:
|
||||||
copy_state.update(running=True, progress=0, error=None,
|
copy_state.update(running=True, progress=0, error=None,
|
||||||
@@ -809,7 +810,8 @@ def do_copy(src_devs, dst_dev, cfg):
|
|||||||
add_log('Fertig! ' + ', '.join(msg_parts))
|
add_log('Fertig! ' + ', '.join(msg_parts))
|
||||||
|
|
||||||
dst_dir_root = Path(dst_mp) / date_str
|
dst_dir_root = Path(dst_mp) / date_str
|
||||||
threading.Thread(target=run_uploads, args=(dst_dir_root, cfg), daemon=True).start()
|
_upload_thread = threading.Thread(target=run_uploads, args=(dst_dir_root, cfg), daemon=True)
|
||||||
|
_upload_thread.start()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.exception('Copy failed')
|
log.exception('Copy failed')
|
||||||
@@ -818,6 +820,10 @@ def do_copy(src_devs, dst_dev, cfg):
|
|||||||
add_log(f'Fehler: {e}')
|
add_log(f'Fehler: {e}')
|
||||||
|
|
||||||
finally:
|
finally:
|
||||||
|
# Erst warten bis NAS-Upload fertig, dann erst unmounten
|
||||||
|
if _upload_thread is not None and _upload_thread.is_alive():
|
||||||
|
add_log('Warte auf NAS-Upload vor Unmount...')
|
||||||
|
_upload_thread.join()
|
||||||
subprocess.run(['sync'], capture_output=True)
|
subprocess.run(['sync'], capture_output=True)
|
||||||
for _, src_mp_i, src_owned_i in src_mounts:
|
for _, src_mp_i, src_owned_i in src_mounts:
|
||||||
if src_owned_i and src_mp_i:
|
if src_owned_i and src_mp_i:
|
||||||
@@ -947,6 +953,7 @@ def run_uploads(local_dir: Path, cfg: dict):
|
|||||||
dest_root = t.get('dest_path', 'PiCopy').strip('/')
|
dest_root = t.get('dest_path', 'PiCopy').strip('/')
|
||||||
dest = f'{_remote_name(t["id"])}:{dest_root}'
|
dest = f'{_remote_name(t["id"])}:{dest_root}'
|
||||||
|
|
||||||
|
_rclone('mkdir', dest, timeout=30) # Zielordner anlegen falls nicht vorhanden
|
||||||
r = _rclone('copy', str(local_dir), dest,
|
r = _rclone('copy', str(local_dir), dest,
|
||||||
'--create-empty-src-dirs',
|
'--create-empty-src-dirs',
|
||||||
'--retries', '3',
|
'--retries', '3',
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
1.0.39
|
1.0.40
|
||||||
Reference in New Issue
Block a user