From df0f3f42f9e18e5f800da0d34d35dabad76cd963 Mon Sep 17 00:00:00 2001 From: Tobias Leuschner Date: Sat, 9 May 2026 13:31:57 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20Upload-Thread-Management=20verbessert?= =?UTF-8?q?=20und=20Versionsnummer=20auf=201.0.40=20erh=C3=B6ht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 9 ++++++++- version.txt | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/app.py b/app.py index 92e4abb..0bab098 100644 --- a/app.py +++ b/app.py @@ -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', diff --git a/version.txt b/version.txt index 99f7422..cd63089 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -1.0.39 \ No newline at end of file +1.0.40 \ No newline at end of file