feat: Upload-Logik verbessert, um nur neue Dateien hochzuladen; Versionsnummer auf 1.0.50 erhöht

This commit is contained in:
2026-05-09 14:11:51 +02:00
parent dedcfc638d
commit 2ce8e95623
2 changed files with 29 additions and 9 deletions

36
app.py
View File

@@ -812,8 +812,16 @@ 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
_upload_thread = threading.Thread(target=run_uploads, args=(dst_dir_root, cfg), daemon=True) upload_files = [dst_f for _, dst_f in verified_pairs if dst_f.exists()]
_upload_thread.start() if upload_files:
_upload_thread = threading.Thread(
target=run_uploads,
args=(dst_dir_root, cfg, upload_files),
daemon=True
)
_upload_thread.start()
elif any(t.get('enabled') for t in cfg.get('upload_targets', [])):
add_log('NAS-Upload: keine neu auf das Ziel übertragenen Dateien')
except Exception as e: except Exception as e:
log.exception('Copy failed') log.exception('Copy failed')
@@ -1088,8 +1096,8 @@ def test_remote(tid):
return True, '' return True, ''
def run_uploads(local_dir: Path, cfg: dict): def run_uploads(local_dir: Path, cfg: dict, upload_files=None):
"""Lädt local_dir zu allen aktiven Fernzielen hoch. Läuft im Background-Thread.""" """Lädt die zuletzt lokal geschriebenen Dateien zu allen aktiven Fernzielen hoch."""
targets = [t for t in cfg.get('upload_targets', []) if t.get('enabled')] targets = [t for t in cfg.get('upload_targets', []) if t.get('enabled')]
if not targets: if not targets:
return return
@@ -1145,16 +1153,28 @@ def run_uploads(local_dir: Path, cfg: dict):
# 3. Kopieren mit Fortschritt # 3. Kopieren mit Fortschritt
add_log(f'Upload {name}: starte copy von {local_dir}') add_log(f'Upload {name}: starte copy von {local_dir}')
dup_mode = cfg.get('duplicate_handling', 'skip') dup_mode = cfg.get('duplicate_handling', 'skip')
files = sorted(f for f in local_dir.rglob('*') if f.is_file()) if upload_files is None:
dirs = sorted(d for d in local_dir.rglob('*') if d.is_dir()) files = sorted(f for f in local_dir.rglob('*') if f.is_file())
else:
files = []
for f in upload_files:
f = Path(f)
try:
f.relative_to(local_dir)
except ValueError:
continue
if f.is_file():
files.append(f)
files = sorted(files)
dirs = sorted({p for f in files for p in f.relative_to(local_dir).parents
if str(p) != '.'})
bytes_total = sum(f.stat().st_size for f in files) bytes_total = sum(f.stat().st_size for f in files)
with upload_lock: with upload_lock:
upload_state.update(total=len(files), bytes_total=bytes_total, upload_state.update(total=len(files), bytes_total=bytes_total,
progress=100 if not files else 0) progress=100 if not files else 0)
for d in dirs: for d in dirs:
rel_dir = d.relative_to(local_dir).as_posix() _rclone('mkdir', _smb_conn(t, _join_remote_path(dest_rel, d.as_posix())), timeout=30)
_rclone('mkdir', _smb_conn(t, _join_remote_path(dest_rel, rel_dir)), timeout=30)
errors = [] errors = []
skipped = 0 skipped = 0

View File

@@ -1 +1 @@
1.0.49 1.0.50