feat: Upload-Thread-Management verbessert und Versionsnummer auf 1.0.40 erhöht

This commit is contained in:
2026-05-09 13:31:57 +02:00
parent af448da749
commit df0f3f42f9
2 changed files with 9 additions and 2 deletions

9
app.py
View File

@@ -589,6 +589,7 @@ def do_copy(src_devs, dst_dev, cfg):
dst_mp = None
dst_owned = False
src_mounts = [] # [(src_dev, src_mp, src_owned)]
_upload_thread = None
try:
with copy_lock:
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))
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:
log.exception('Copy failed')
@@ -818,6 +820,10 @@ def do_copy(src_devs, dst_dev, cfg):
add_log(f'Fehler: {e}')
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)
for _, src_mp_i, src_owned_i in src_mounts:
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 = f'{_remote_name(t["id"])}:{dest_root}'
_rclone('mkdir', dest, timeout=30) # Zielordner anlegen falls nicht vorhanden
r = _rclone('copy', str(local_dir), dest,
'--create-empty-src-dirs',
'--retries', '3',