4 Commits
Author SHA1 Message Date
Davito cdcd03d7b0 Release SyncVito 1.0.13 2026-09-28 11:08:14 +02:00
Davito b6e32a1b18 Release SyncVito 1.0.12 2026-09-27 23:48:19 +02:00
Davito 786e3ae9b3 Release SyncVito 1.0.12 2026-09-27 23:46:11 +02:00
Davito ccb89191b5 Release SyncVito 1.0.11 2026-09-27 22:42:23 +02:00
14 changed files with 503 additions and 33 deletions

No files matched your search

+28
View File
@@ -1,5 +1,33 @@
# Änderungsprotokoll # Änderungsprotokoll
## 1.0.13 – 2026-09-28
### Behoben
- **Zuverlässiger Windows-Autostart via Aufgabenplanung:** Da SyncVito mit Administratorrechten (`requireAdministrator`) läuft, blockierte der Windows Explorer beim Systemstart den Aufruf aus dem Registry-`Run`-Schlüssel. Der Autostart wird nun über eine geplante Windows-Aufgabe (`RunLevel=HighestAvailable`) bei Benutzeranmeldung ausgeführt, sodass SyncVito nach dem Hochfahren zuverlässig und ohne UAC-Dialog im Infobereich startet.
- **Warteschleife für den Windows-Infobereich:** Falls der Windows Explorer beim Booten den Benachrichtigungsbereich noch nicht initialisiert hat, wartet SyncVito bis zu 15 Sekunden auf den Tray, statt sich sofort mit einem Fehler zu beenden.
- **Automatische Autostart-Migration:** Bestehende Konfigurationen mit aktiviertem Autostart werden beim Programmstart automatisch auf die geplante Aufgabe umgestellt; alte Einträge im Run-Schlüssel werden bereinigt.
- **Saubere Deinstallation:** Bei einer Deinstallation über Inno Setup wird die registrierte Windows-Aufgabe für den Autostart automatisch entfernt.
## 1.0.12 – 2026-09-27
### Behoben
- **Endlosschleife bei Wiederholungen beseitigt:** Aufgaben in Wiederholungsschleifen werden nach dem Einreihen sauber aus der Retry-Warteliste entfernt und bei reinen Fehlern ohne gesperrte Dateien nicht mehr dauerhaft im 10-Sekunden-Takt neu gestartet.
- **Wiederholungs-Backoff und Versuchslimit:** Für gesperrte Dateien greift ein exponentielles Backoff (30s, 60s, 120s bis max. 300s) sowie ein Limit von 5 automatischen Versuchen, um Festplatte, Netzwerk und Prozessor vor unnötigen Dauerläufen zu schützen.
- **Flüchtige Cache-Dateien ohne Fehlermeldung:** Dateien, die zwischen Inventarerstellung und Kopiervorgang gelöscht wurden (z. B. dynamische Browser- oder Anwendungs-Caches), werden sauber als übersprungen gewertet und brechen die Sicherung nicht mehr mit `[WinError 2]` ab.
- **Kein Einfrieren der Benutzeroberfläche:** Das automatische Weiterscrollen der Protokolltabelle bei vielen gleichzeitigen Meldungen wird gebündelt entprellt, die Abfrage des Windows Restart Managers für gesperrte Ordner wird pro Verzeichnis zwischengespeichert und Fortschrittsmeldungen werden im GUI-Thread gedrosselt.
## 1.0.11 – 2026-09-27
### Behoben
- Der Button „Pausieren“ ist im Leerlauf deaktiviert, damit SyncVito nicht versehentlich ohne aktive Aufgabe in den Pausenzustand versetzt werden kann.
- Beim Klick auf „Alle jetzt synchronisieren“ oder „Auswahl synchronisieren“ wird ein eventuell aktiver Pausenzustand automatisch aufgehoben und der Lauf sofort gestartet.
- Klickt man auf „Fortsetzen“, wenn zuvor noch keine Aufgabe eingereiht war, startet SyncVito direkt alle aktiven Aufgaben, statt wirkungslos zu bleiben.
- Die automatische Hintergrund-Updateprüfung setzt die Fortschrittsleiste im Leerlauf nicht mehr dauerhaft auf 100 % mit „SyncVito ist aktuell“, sondern die Leiste bleibt ordnungsgemäß auf „Bereit“.
- Die Tray-Benachrichtigung beim Schließen des Fensters lautet nun unmissverständlich „SyncVito minimiert“ statt „SyncVito läuft weiter“.
## 1.0.10 – 2026-09-27 ## 1.0.10 – 2026-09-27
### Neu ### Neu
+17 -1
View File
@@ -150,7 +150,23 @@ VSVersionInfo(
if ($LASTEXITCODE -ne 0) { throw "Der Release-Commit ist fehlgeschlagen." } if ($LASTEXITCODE -ne 0) { throw "Der Release-Commit ist fehlgeschlagen." }
} }
$sourceCommitted = $true $sourceCommitted = $true
git push origin main $pushTarget = "origin"
$tokenPath = @(
(Join-Path $env:LOCALAPPDATA "SyncVito\developer\gitea-token.dpapi"),
(Join-Path $env:LOCALAPPDATA "MusicBrain\developer\gitea-token.dpapi")
) | Where-Object { Test-Path -LiteralPath $_ -PathType Leaf } | Select-Object -First 1
if (-not [string]::IsNullOrWhiteSpace($env:GITEA_TOKEN)) {
$pushTarget = "https://Davito:$($env:GITEA_TOKEN.Trim())@gitea.davito.synology.me/Davito/SyncVito.git"
}
elseif ($tokenPath) {
try {
$sec = (Get-Content $tokenPath -Raw).Trim() | ConvertTo-SecureString
$bstr = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($sec)
$t = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($bstr)
$pushTarget = "https://Davito:$t@gitea.davito.synology.me/Davito/SyncVito.git"
} catch { }
}
git push $pushTarget main
if ($LASTEXITCODE -ne 0) { throw "Der Quellstand konnte nicht nach Gitea gepusht werden." } if ($LASTEXITCODE -ne 0) { throw "Der Quellstand konnte nicht nach Gitea gepusht werden." }
} }
+3
View File
@@ -55,3 +55,6 @@ Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: de
[Run] [Run]
Filename: "{app}\{#MyAppExeName}"; Description: "{#MyAppName} starten"; Flags: nowait postinstall skipifsilent runascurrentuser Filename: "{app}\{#MyAppExeName}"; Description: "{#MyAppName} starten"; Flags: nowait postinstall skipifsilent runascurrentuser
Filename: "{app}\{#MyAppExeName}"; Parameters: "--updated"; Flags: nowait skipifnotsilent runascurrentuser Filename: "{app}\{#MyAppExeName}"; Parameters: "--updated"; Flags: nowait skipifnotsilent runascurrentuser
[UninstallRun]
Filename: "schtasks.exe"; Parameters: "/delete /tn ""{#MyAppName}"" /f"; Flags: runhidden
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "syncvito" name = "syncvito"
version = "1.0.10" version = "1.0.13"
description = "Windows-Desktopwerkzeug für lokale und NAS-Synchronisation" description = "Windows-Desktopwerkzeug für lokale und NAS-Synchronisation"
readme = "README.md" readme = "README.md"
requires-python = ">=3.11" requires-python = ">=3.11"
+20 -2
View File
@@ -2,12 +2,15 @@
from __future__ import annotations from __future__ import annotations
import os
import sys import sys
import time
from pathlib import Path from pathlib import Path
from PyQt6.QtCore import QLockFile, QStandardPaths from PyQt6.QtCore import QLockFile, QStandardPaths
from PyQt6.QtWidgets import QApplication, QMessageBox, QSystemTrayIcon from PyQt6.QtWidgets import QApplication, QMessageBox, QSystemTrayIcon
from syncvito.autostart import set_autostart
from syncvito.config_store import ConfigError, ConfigStore from syncvito.config_store import ConfigError, ConfigStore
from syncvito.icons import app_icon from syncvito.icons import app_icon
from syncvito.main_window import MainWindow from syncvito.main_window import MainWindow
@@ -18,6 +21,19 @@ from syncvito.version import __version__
__all__ = ["main"] __all__ = ["main"]
def _wait_for_system_tray(application: QApplication, timeout_seconds: float = 15.0) -> bool:
"""Wartet beim Windows-Start auf die Verfügbarkeit des Infobereichs."""
if QSystemTrayIcon.isSystemTrayAvailable():
return True
deadline = time.monotonic() + timeout_seconds
while time.monotonic() < deadline:
application.processEvents()
time.sleep(0.25)
if QSystemTrayIcon.isSystemTrayAvailable():
return True
return False
def main() -> int: def main() -> int:
"""Startet SyncVito als einzelne Windows-Instanz.""" """Startet SyncVito als einzelne Windows-Instanz."""
if "--version" in sys.argv: if "--version" in sys.argv:
@@ -33,11 +49,11 @@ def main() -> int:
lock_path = Path(QStandardPaths.writableLocation(QStandardPaths.StandardLocation.TempLocation)) / "syncvito.lock" lock_path = Path(QStandardPaths.writableLocation(QStandardPaths.StandardLocation.TempLocation)) / "syncvito.lock"
lock = QLockFile(str(lock_path)) lock = QLockFile(str(lock_path))
lock.setStaleLockTime(0) lock.setStaleLockTime(30000)
if not lock.tryLock(100): if not lock.tryLock(100):
QMessageBox.information(None, "SyncVito läuft bereits", "SyncVito ist bereits im Infobereich aktiv.") QMessageBox.information(None, "SyncVito läuft bereits", "SyncVito ist bereits im Infobereich aktiv.")
return 0 return 0
if not QSystemTrayIcon.isSystemTrayAvailable(): if not _wait_for_system_tray(application):
QMessageBox.critical(None, "Infobereich nicht verfügbar", "SyncVito benötigt den Windows-Infobereich.") QMessageBox.critical(None, "Infobereich nicht verfügbar", "SyncVito benötigt den Windows-Infobereich.")
return 1 return 1
@@ -47,6 +63,8 @@ def main() -> int:
except ConfigError as exc: except ConfigError as exc:
QMessageBox.warning(None, "Konfiguration zurückgesetzt", str(exc)) QMessageBox.warning(None, "Konfiguration zurückgesetzt", str(exc))
config = AppConfig() config = AppConfig()
if os.name == "nt" and config.settings.autostart:
set_autostart(True)
apply_theme(application, config.settings) apply_theme(application, config.settings)
window = MainWindow(config, store) window = MainWindow(config, store)
if "--minimized" not in sys.argv: if "--minimized" not in sys.argv:
+140 -15
View File
@@ -3,29 +3,154 @@
from __future__ import annotations from __future__ import annotations
import os import os
import subprocess
import sys import sys
import tempfile
from contextlib import suppress from contextlib import suppress
from pathlib import Path from pathlib import Path
from xml.sax.saxutils import escape as xml_escape
__all__ = ["set_autostart"] __all__ = ["RUN_KEY_PATH", "TASK_NAME", "generate_task_xml", "set_autostart"]
TASK_NAME = "SyncVito"
RUN_KEY_PATH = r"Software\Microsoft\Windows\CurrentVersion\Run"
def set_autostart(enabled: bool) -> None: def generate_task_xml(command_exe: Path, arguments: str = "--minimized") -> str:
"""Setzt oder entfernt SyncVito unter HKCU\\...\\Run.""" """Erzeugt die XML-Definition für die Windows-Aufgabenplanung."""
escaped_exe = xml_escape(str(command_exe.resolve()))
escaped_args = xml_escape(arguments)
return (
'<?xml version="1.0" encoding="UTF-16"?>\n'
'<Task version="1.2" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">\n'
" <RegistrationInfo>\n"
" <Description>SyncVito Windows Autostart</Description>\n"
" </RegistrationInfo>\n"
" <Triggers>\n"
" <LogonTrigger>\n"
" <Enabled>true</Enabled>\n"
" <Delay>PT5S</Delay>\n"
" </LogonTrigger>\n"
" </Triggers>\n"
" <Principals>\n"
' <Principal id="Author">\n'
" <LogonType>InteractiveToken</LogonType>\n"
" <RunLevel>HighestAvailable</RunLevel>\n"
" </Principal>\n"
" </Principals>\n"
" <Settings>\n"
" <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>\n"
" <DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>\n"
" <StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>\n"
" <AllowHardTerminate>true</AllowHardTerminate>\n"
" <StartWhenAvailable>true</StartWhenAvailable>\n"
" <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>\n"
" <IdleSettings>\n"
" <StopOnIdleEnd>false</StopOnIdleEnd>\n"
" <RestartOnIdle>false</RestartOnIdle>\n"
" </IdleSettings>\n"
" <AllowStartOnDemand>true</AllowStartOnDemand>\n"
" <Enabled>true</Enabled>\n"
" <Hidden>false</Hidden>\n"
" <RunOnlyIfIdle>false</RunOnlyIfIdle>\n"
" <WakeToRun>false</WakeToRun>\n"
" <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>\n"
" <Priority>7</Priority>\n"
" </Settings>\n"
' <Actions Context="Author">\n'
" <Exec>\n"
f" <Command>{escaped_exe}</Command>\n"
f" <Arguments>{escaped_args}</Arguments>\n"
" </Exec>\n"
" </Actions>\n"
"</Task>"
)
def _run_schtasks(args: list[str]) -> subprocess.CompletedProcess[str]:
flags = getattr(subprocess, "CREATE_NO_WINDOW", 0) if os.name == "nt" else 0
return subprocess.run(
["schtasks", *args],
capture_output=True,
text=True,
creationflags=flags,
check=False,
)
def _delete_run_key_entry() -> None:
if os.name != "nt": if os.name != "nt":
return return
import winreg import winreg
key_path = r"Software\Microsoft\Windows\CurrentVersion\Run" with (
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, key_path, 0, winreg.KEY_SET_VALUE) as key: suppress(FileNotFoundError, OSError),
if enabled: winreg.OpenKey(winreg.HKEY_CURRENT_USER, RUN_KEY_PATH, 0, winreg.KEY_SET_VALUE) as key,
executable = Path(sys.executable) ):
if getattr(sys, "frozen", False): winreg.DeleteValue(key, TASK_NAME)
command = f'"{executable}" --minimized'
else:
entry = Path(__file__).resolve().parents[2] / "main.py" def _set_run_key_entry(command: str) -> None:
command = f'"{executable}" "{entry}" --minimized' if os.name != "nt":
winreg.SetValueEx(key, "SyncVito", 0, winreg.REG_SZ, command) return
import winreg
with winreg.OpenKey(winreg.HKEY_CURRENT_USER, RUN_KEY_PATH, 0, winreg.KEY_SET_VALUE) as key:
winreg.SetValueEx(key, TASK_NAME, 0, winreg.REG_SZ, command)
def _register_scheduled_task(command_exe: Path, arguments: str) -> bool:
xml_content = generate_task_xml(command_exe, arguments)
fd, tmp_file = tempfile.mkstemp(suffix=".xml")
tmp_path = Path(tmp_file)
try:
with os.fdopen(fd, "w", encoding="utf-16") as f:
f.write(xml_content)
result = _run_schtasks(["/create", "/tn", TASK_NAME, "/xml", str(tmp_path), "/f"])
return result.returncode == 0
except OSError:
return False
finally:
with suppress(OSError):
tmp_path.unlink()
def _delete_scheduled_task() -> bool:
result = _run_schtasks(["/delete", "/tn", TASK_NAME, "/f"])
return result.returncode == 0
def set_autostart(enabled: bool) -> bool:
"""Aktiviert oder entfernt SyncVito im Windows-Autostart.
Da SyncVito Administratorrechte (requireAdministrator) benötigt,
ignoriert der Windows-Explorer Einträge unter HKCU\\...\\Run beim Systemstart
vollständig, um unerwünschte UAC-Abfragen beim Logon zu verhindern.
Für erhöhte Anwendungen muss daher ein Scheduled Task in der Windows-
Aufgabenplanung mit 'RunLevel=HighestAvailable' verwendet werden.
"""
if os.name != "nt":
return False
if enabled:
if getattr(sys, "frozen", False):
command_exe = Path(sys.executable)
arguments = "--minimized"
reg_command = f'"{command_exe}" --minimized'
else: else:
with suppress(FileNotFoundError): command_exe = Path(sys.executable)
winreg.DeleteValue(key, "SyncVito") entry = Path(__file__).resolve().parents[2] / "main.py"
arguments = f'"{entry}" --minimized'
reg_command = f'"{command_exe}" "{entry}" --minimized'
if _register_scheduled_task(command_exe, arguments):
_delete_run_key_entry()
return True
# Fallback auf Run-Schlüssel (z. B. nicht-erhöhte Entwicklungsumgebung)
_set_run_key_entry(reg_command)
return False
else:
_delete_scheduled_task()
_delete_run_key_entry()
return True
+54 -4
View File
@@ -88,6 +88,8 @@ class SyncCoordinator(QObject):
self._queue: deque[str] = deque() self._queue: deque[str] = deque()
self._running_task_id: str | None = None self._running_task_id: str | None = None
self._retry_tasks: dict[str, list[Path]] = {} self._retry_tasks: dict[str, list[Path]] = {}
self._retry_attempts: dict[str, int] = {}
self._retry_cooldowns: dict[str, datetime] = {}
self._lock_messages: dict[str, str] = {} self._lock_messages: dict[str, str] = {}
self._task_states: dict[str, TaskRuntimeState] = { self._task_states: dict[str, TaskRuntimeState] = {
task.id: TaskRuntimeState.ACTIVE if task.enabled else TaskRuntimeState.PAUSED for task in config.tasks task.id: TaskRuntimeState.ACTIVE if task.enabled else TaskRuntimeState.PAUSED for task in config.tasks
@@ -142,6 +144,8 @@ class SyncCoordinator(QObject):
known_ids = {task.id for task in self.config.tasks} known_ids = {task.id for task in self.config.tasks}
self._task_states = {task_id: state for task_id, state in self._task_states.items() if task_id in known_ids} self._task_states = {task_id: state for task_id, state in self._task_states.items() if task_id in known_ids}
self._retry_tasks = {task_id: paths for task_id, paths in self._retry_tasks.items() if task_id in known_ids} self._retry_tasks = {task_id: paths for task_id, paths in self._retry_tasks.items() if task_id in known_ids}
self._retry_attempts = {task_id: att for task_id, att in self._retry_attempts.items() if task_id in known_ids}
self._retry_cooldowns = {task_id: cd for task_id, cd in self._retry_cooldowns.items() if task_id in known_ids}
self._lock_messages = { self._lock_messages = {
task_id: message for task_id, message in self._lock_messages.items() if task_id in known_ids task_id: message for task_id, message in self._lock_messages.items() if task_id in known_ids
} }
@@ -152,6 +156,8 @@ class SyncCoordinator(QObject):
self._set_task_state(task.id, desired) self._set_task_state(task.id, desired)
if not task.enabled: if not task.enabled:
self._retry_tasks.pop(task.id, None) self._retry_tasks.pop(task.id, None)
self._retry_attempts.pop(task.id, None)
self._retry_cooldowns.pop(task.id, None)
self._lock_messages.pop(task.id, None) self._lock_messages.pop(task.id, None)
enabled_ids = {task.id for task in self.config.tasks if task.enabled} enabled_ids = {task.id for task in self.config.tasks if task.enabled}
self._queue = deque(task_id for task_id in self._queue if task_id in enabled_ids) self._queue = deque(task_id for task_id in self._queue if task_id in enabled_ids)
@@ -179,6 +185,8 @@ class SyncCoordinator(QObject):
task = self._task(task_id) task = self._task(task_id)
if task is None or not task.enabled: if task is None or not task.enabled:
return return
self._retry_attempts.pop(task_id, None)
self._retry_cooldowns.pop(task_id, None)
if self.config.settings.paused: if self.config.settings.paused:
if task_id != self._running_task_id and task_id not in self._queue: if task_id != self._running_task_id and task_id not in self._queue:
self._queue.append(task_id) self._queue.append(task_id)
@@ -194,6 +202,8 @@ class SyncCoordinator(QObject):
def enqueue_all(self) -> None: def enqueue_all(self) -> None:
"""Stellt alle aktiven Aufgaben zur manuellen Ausführung an.""" """Stellt alle aktiven Aufgaben zur manuellen Ausführung an."""
if self.config.settings.paused:
self.set_paused(False)
for task in self.config.tasks: for task in self.config.tasks:
if task.enabled: if task.enabled:
self.enqueue(task.id) self.enqueue(task.id)
@@ -213,6 +223,10 @@ class SyncCoordinator(QObject):
for tid in self.config.settings.pending_queue: for tid in self.config.settings.pending_queue:
if tid not in self._queue and any(t.id == tid and t.enabled for t in self.config.tasks): if tid not in self._queue and any(t.id == tid and t.enabled for t in self.config.tasks):
self._queue.append(tid) self._queue.append(tid)
if not self._queue and not self._running_task_id:
for task in self.config.tasks:
if task.enabled:
self._queue.append(task.id)
self._start_next() self._start_next()
with suppress(Exception): with suppress(Exception):
self.config_store.save(self.config) self.config_store.save(self.config)
@@ -223,7 +237,9 @@ class SyncCoordinator(QObject):
"""Aktualisiert alle Dateisystemüberwachungen.""" """Aktualisiert alle Dateisystemüberwachungen."""
errors = self.monitor.rebuild(self.config.tasks) errors = self.monitor.rebuild(self.config.tasks)
for task_id, message in errors: for task_id, message in errors:
self._retry_tasks[task_id] = [] self._retry_tasks.pop(task_id, None)
self._retry_attempts.pop(task_id, None)
self._retry_cooldowns.pop(task_id, None)
self._set_task_state(task_id, TaskRuntimeState.ERROR) self._set_task_state(task_id, TaskRuntimeState.ERROR)
self.log_created.emit("Echtzeit", "Fehler", message) self.log_created.emit("Echtzeit", "Fehler", message)
self._emit_overall_status() self._emit_overall_status()
@@ -309,12 +325,17 @@ class SyncCoordinator(QObject):
self._emit_lock_summary() self._emit_lock_summary()
if result.errors: if result.errors:
# Auch zusätzliche Fehler eines teilweise blockierten Laufs sichtbar halten. # Auch zusätzliche Fehler eines teilweise blockierten Laufs sichtbar halten.
self._retry_tasks[task_id] = [] if not result.blocked:
self._retry_tasks.pop(task_id, None)
self._retry_attempts.pop(task_id, None)
self._retry_cooldowns.pop(task_id, None)
for error in result.errors: for error in result.errors:
self.log_created.emit(task.name, "Fehler", error) self.log_created.emit(task.name, "Fehler", error)
self._set_task_state(task_id, TaskRuntimeState.ERROR) self._set_task_state(task_id, TaskRuntimeState.ERROR)
elif not result.blocked: elif not result.blocked:
self._retry_tasks.pop(task_id, None) self._retry_tasks.pop(task_id, None)
self._retry_attempts.pop(task_id, None)
self._retry_cooldowns.pop(task_id, None)
summary = f"{result.copied} kopiert, {result.deleted} gelöscht, {result.conflicts} Konfliktkopien" summary = f"{result.copied} kopiert, {result.deleted} gelöscht, {result.conflicts} Konfliktkopien"
self.log_created.emit(task.name, "Erfolg", summary) self.log_created.emit(task.name, "Erfolg", summary)
self._set_task_state(task_id, TaskRuntimeState.ACTIVE) self._set_task_state(task_id, TaskRuntimeState.ACTIVE)
@@ -323,7 +344,9 @@ class SyncCoordinator(QObject):
def _on_failed(self, task_id: str, detail: str, inaccessible: bool) -> None: def _on_failed(self, task_id: str, detail: str, inaccessible: bool) -> None:
task = self._task(task_id) task = self._task(task_id)
name = task.name if task else "Aufgabe" name = task.name if task else "Aufgabe"
self._retry_tasks[task_id] = [] self._retry_tasks.pop(task_id, None)
self._retry_attempts.pop(task_id, None)
self._retry_cooldowns.pop(task_id, None)
self._lock_messages.pop(task_id, None) self._lock_messages.pop(task_id, None)
self._emit_lock_summary() self._emit_lock_summary()
self._set_task_state(task_id, TaskRuntimeState.ERROR) self._set_task_state(task_id, TaskRuntimeState.ERROR)
@@ -366,9 +389,36 @@ class SyncCoordinator(QObject):
def _check_retries(self) -> None: def _check_retries(self) -> None:
if self.config.settings.paused or self.is_running: if self.config.settings.paused or self.is_running:
return return
now = datetime.now()
ready_tasks: list[str] = []
for task_id, paths in list(self._retry_tasks.items()): for task_id, paths in list(self._retry_tasks.items()):
if paths and all(is_file_locked(path) for path in paths): cooldown_until = self._retry_cooldowns.get(task_id)
if cooldown_until and now < cooldown_until:
continue continue
attempts = self._retry_attempts.get(task_id, 0)
if attempts >= 5:
if attempts == 5:
task = self._task(task_id)
name = task.name if task else task_id
self.log_created.emit(
name,
"Hinweis",
"Automatische Wiederholungen vorübergehend ausgesetzt. Bitte sperrende Programme schließen.",
)
self._retry_attempts[task_id] = attempts + 1
continue
check_paths = paths[:10] if len(paths) > 10 else paths
if paths and all(is_file_locked(path) for path in check_paths):
continue
ready_tasks.append(task_id)
for task_id in ready_tasks:
self._retry_tasks.pop(task_id, None)
attempts = self._retry_attempts.get(task_id, 0) + 1
self._retry_attempts[task_id] = attempts
backoff_seconds = min(300, 30 * (2 ** min(attempts - 1, 4)))
self._retry_cooldowns[task_id] = now + timedelta(seconds=backoff_seconds)
self.log_created.emit( self.log_created.emit(
"Automatischer Versuch", "Hinweis", "Blockierte oder nicht erreichbare Datei wird erneut geprüft." "Automatischer Versuch", "Hinweis", "Blockierte oder nicht erreichbare Datei wird erneut geprüft."
) )
+39 -6
View File
@@ -140,8 +140,8 @@ class MainWindow(QMainWindow):
event.ignore() event.ignore()
self.hide() self.hide()
self.tray.showMessage( self.tray.showMessage(
"SyncVito läuft weiter", "SyncVito minimiert",
"Das Fenster wurde in den Infobereich verschoben.", "SyncVito bleibt im Infobereich aktiv.",
QSystemTrayIcon.MessageIcon.Information, QSystemTrayIcon.MessageIcon.Information,
2500, 2500,
) )
@@ -572,6 +572,8 @@ class MainWindow(QMainWindow):
if task is None: if task is None:
QMessageBox.information(self, "Keine Auswahl", "Bitte zuerst eine Aufgabe auswählen.") QMessageBox.information(self, "Keine Auswahl", "Bitte zuerst eine Aufgabe auswählen.")
return return
if self.config.settings.paused:
self.coordinator.set_paused(False)
self.coordinator.enqueue(task.id) self.coordinator.enqueue(task.id)
def _persist_tasks(self, message: str) -> None: def _persist_tasks(self, message: str) -> None:
@@ -652,10 +654,18 @@ class MainWindow(QMainWindow):
self._mark_update_checked() self._mark_update_checked()
self._set_update_indicator(None) self._set_update_indicator(None)
self._notified_update_version = None self._notified_update_version = None
self._update_progress(100, "SyncVito ist aktuell")
self._append_log("Update", "Erfolg", "Die installierte Version ist aktuell.") self._append_log("Update", "Erfolg", "Die installierte Version ist aktuell.")
if manual: if manual:
self._update_progress(100, "SyncVito ist aktuell")
QMessageBox.information(self, "Keine Updates", "Du verwendest bereits die aktuelle SyncVito-Version.") QMessageBox.information(self, "Keine Updates", "Du verwendest bereits die aktuelle SyncVito-Version.")
elif not self.coordinator.is_running:
self.progress_text.setText("SyncVito ist aktuell")
QTimer.singleShot(3000, self._reset_idle_progress)
def _reset_idle_progress(self) -> None:
if not self.coordinator.is_running and not self.config.settings.paused:
self.progress_text.setText("Bereit")
self.progress_bar.setValue(0)
def _on_update_error(self, message: str, manual: bool) -> None: def _on_update_error(self, message: str, manual: bool) -> None:
self._update_progress(0, "Updateprüfung fehlgeschlagen") self._update_progress(0, "Updateprüfung fehlgeschlagen")
@@ -740,18 +750,32 @@ class MainWindow(QMainWindow):
def _update_pause_action(self) -> None: def _update_pause_action(self) -> None:
is_paused = self.config.settings.paused is_paused = self.config.settings.paused
is_running = self.coordinator.is_running
has_queue = bool(self.coordinator.queued_task_ids)
if is_paused: if is_paused:
btn_text = "▶ Fortsetzen" btn_text = "▶ Fortsetzen"
tray_text = "Fortsetzen" tray_text = "Fortsetzen"
else: btn_enabled = True
btn_text = "⏸ Pausieren" if self.coordinator.is_running else "Pausieren" primary = True
elif is_running or has_queue:
btn_text = "⏸ Pausieren"
tray_text = "Pausieren" tray_text = "Pausieren"
btn_enabled = True
primary = False
else:
btn_text = "Pausieren"
tray_text = "Pausieren"
btn_enabled = False
primary = False
self.pause_action.setText(tray_text) self.pause_action.setText(tray_text)
self.pause_action.setEnabled(btn_enabled)
for btn in (getattr(self, "header_pause_button", None), getattr(self, "dock_pause_button", None)): for btn in (getattr(self, "header_pause_button", None), getattr(self, "dock_pause_button", None)):
if btn is not None: if btn is not None:
btn.setText(btn_text) btn.setText(btn_text)
btn.setProperty("primary", is_paused) btn.setEnabled(btn_enabled)
btn.setProperty("primary", primary)
btn.style().unpolish(btn) btn.style().unpolish(btn)
btn.style().polish(btn) btn.style().polish(btn)
@@ -779,6 +803,15 @@ class MainWindow(QMainWindow):
self.log_table.setItem(row, column, item) self.log_table.setItem(row, column, item)
if self.log_table.rowCount() > 1000: if self.log_table.rowCount() > 1000:
self.log_table.removeRow(0) self.log_table.removeRow(0)
self._schedule_log_scroll()
def _schedule_log_scroll(self) -> None:
if not getattr(self, "_log_scroll_pending", False):
self._log_scroll_pending = True
QTimer.singleShot(50, self._do_scroll_log)
def _do_scroll_log(self) -> None:
self._log_scroll_pending = False
self.log_table.scrollToBottom() self.log_table.scrollToBottom()
def _set_global_status(self, status: str, text: str) -> None: def _set_global_status(self, status: str, text: str) -> None:
+28 -2
View File
@@ -141,6 +141,11 @@ class SyncEngine:
if stage_name not in stages: if stage_name not in stages:
stages.append(stage_name) stages.append(stage_name)
known_locking_processes: dict[Path, tuple[LockingProcess, ...]] = {}
rm_query_count = 0
last_progress_time = 0.0
current_stage = ""
if progress: if progress:
progress(0, "Änderungen werden vorbereitet …") progress(0, "Änderungen werden vorbereitet …")
for index, operation in enumerate(operations, start=1): for index, operation in enumerate(operations, start=1):
@@ -154,6 +159,9 @@ class SyncEngine:
try: try:
self._execute(operation, result) self._execute(operation, result)
except (OSError, shutil.Error) as exc: except (OSError, shutil.Error) as exc:
if isinstance(exc, FileNotFoundError) and operation.source and not operation.source.exists():
result.skipped += 1
continue
failed_path = ( failed_path = (
Path(exc.filename2 or exc.filename) Path(exc.filename2 or exc.filename)
if isinstance(exc, OSError) and (exc.filename2 or exc.filename) if isinstance(exc, OSError) and (exc.filename2 or exc.filename)
@@ -161,13 +169,28 @@ class SyncEngine:
) )
blocked_path = _blocked_path(operation, exc) blocked_path = _blocked_path(operation, exc)
if blocked_path is not None: if blocked_path is not None:
processes = tuple(find_locking_processes(blocked_path)) parent_dir = blocked_path.parent
if parent_dir in known_locking_processes:
processes = known_locking_processes[parent_dir]
elif rm_query_count < 10:
discovered = tuple(find_locking_processes(blocked_path))
rm_query_count += 1
if discovered:
known_locking_processes[parent_dir] = discovered
processes = discovered
else:
processes = next(iter(known_locking_processes.values()), ())
result.blocked.append(BlockedFile(blocked_path, processes)) result.blocked.append(BlockedFile(blocked_path, processes))
elif isinstance(exc, PermissionError): elif isinstance(exc, PermissionError):
result.errors.append(f"Zugriff verweigert: {failed_path} ({exc})") result.errors.append(f"Zugriff verweigert: {failed_path} ({exc})")
else: else:
result.errors.append(f"{failed_path}: {exc}") result.errors.append(f"{failed_path}: {exc}")
if progress: now = monotonic()
is_last = index == total
stage_changed = stage != current_stage
if progress and (is_last or stage_changed or now - last_progress_time >= 0.05):
last_progress_time = now
current_stage = stage
if len(stages) > 1: if len(stages) > 1:
stage_idx = stages.index(stage) + 1 stage_idx = stages.index(stage) + 1
detail = f"[{stage_idx}/{len(stages)} {stage}] {operation.kind}: {operation.relative}" detail = f"[{stage_idx}/{len(stages)} {stage}] {operation.kind}: {operation.relative}"
@@ -344,6 +367,9 @@ class SyncEngine:
return return
if operation.source is None: if operation.source is None:
return return
if not operation.source.exists():
result.skipped += 1
return
operation.target.parent.mkdir(parents=True, exist_ok=True) operation.target.parent.mkdir(parents=True, exist_ok=True)
if operation.conflict_copy and operation.target.exists(): if operation.conflict_copy and operation.target.exists():
conflict_path = _conflict_path(operation.target) conflict_path = _conflict_path(operation.target)
+101
View File
@@ -0,0 +1,101 @@
import subprocess
import sys
from pathlib import Path
from unittest.mock import MagicMock
import pytest
import syncvito.autostart as autostart
from syncvito.autostart import generate_task_xml, set_autostart
def test_generate_task_xml_structure() -> None:
cmd = Path("C:/Program Files/SyncVito/SyncVito.exe")
args = "--minimized"
xml = generate_task_xml(cmd, args)
assert '<?xml version="1.0" encoding="UTF-16"?>' in xml
assert "<RunLevel>HighestAvailable</RunLevel>" in xml
assert "<LogonType>InteractiveToken</LogonType>" in xml
assert "<Delay>PT5S</Delay>" in xml
assert "<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>" in xml
assert "<StopIfGoingOnBatteries>false</StopIfGoingOnBatteries>" in xml
assert "<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>" in xml
assert "<Command>C:\\Program Files\\SyncVito\\SyncVito.exe</Command>" in xml
assert "<Arguments>--minimized</Arguments>" in xml
def test_set_autostart_non_windows(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(autostart.os, "name", "posix")
assert not set_autostart(True)
assert not set_autostart(False)
def test_set_autostart_enable_scheduled_task_success(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(autostart.os, "name", "nt")
monkeypatch.setattr(sys, "frozen", True, raising=False)
monkeypatch.setattr(sys, "executable", r"C:\Program Files\SyncVito\SyncVito.exe")
mock_run = MagicMock(return_value=subprocess.CompletedProcess(args=[], returncode=0))
monkeypatch.setattr(autostart, "_run_schtasks", mock_run)
deleted_run_key = False
def mock_delete_run_key() -> None:
nonlocal deleted_run_key
deleted_run_key = True
monkeypatch.setattr(autostart, "_delete_run_key_entry", mock_delete_run_key)
result = set_autostart(True)
assert result is True
assert mock_run.called
create_call_args = mock_run.call_args[0][0]
assert create_call_args[0] == "/create"
assert create_call_args[1] == "/tn"
assert create_call_args[2] == "SyncVito"
assert deleted_run_key is True
def test_set_autostart_enable_fallback_registry(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(autostart.os, "name", "nt")
monkeypatch.setattr(sys, "frozen", True, raising=False)
monkeypatch.setattr(sys, "executable", r"C:\Program Files\SyncVito\SyncVito.exe")
# schtasks fails (e.g. non-elevated prompt)
mock_run = MagicMock(return_value=subprocess.CompletedProcess(args=[], returncode=1))
monkeypatch.setattr(autostart, "_run_schtasks", mock_run)
registry_command = None
def mock_set_run_key(cmd: str) -> None:
nonlocal registry_command
registry_command = cmd
monkeypatch.setattr(autostart, "_set_run_key_entry", mock_set_run_key)
result = set_autostart(True)
assert result is False
assert registry_command == r'"C:\Program Files\SyncVito\SyncVito.exe" --minimized'
def test_set_autostart_disable(monkeypatch: pytest.MonkeyPatch) -> None:
monkeypatch.setattr(autostart.os, "name", "nt")
mock_run = MagicMock(return_value=subprocess.CompletedProcess(args=[], returncode=0))
monkeypatch.setattr(autostart, "_run_schtasks", mock_run)
deleted_run_key = False
def mock_delete_run_key() -> None:
nonlocal deleted_run_key
deleted_run_key = True
monkeypatch.setattr(autostart, "_delete_run_key_entry", mock_delete_run_key)
result = set_autostart(False)
assert result is True
assert mock_run.called
delete_call_args = mock_run.call_args[0][0]
assert delete_call_args == ["/delete", "/tn", "SyncVito", "/f"]
assert deleted_run_key is True
+38
View File
@@ -73,6 +73,30 @@ def test_retry_queues_all_ready_tasks(coordinator: SyncCoordinator, monkeypatch:
monkeypatch.setattr(coordinator, "enqueue", queued.append) monkeypatch.setattr(coordinator, "enqueue", queued.append)
coordinator._check_retries() coordinator._check_retries()
assert queued == ["first", "second"] assert queued == ["first", "second"]
assert "first" not in coordinator._retry_tasks
assert "second" not in coordinator._retry_tasks
def test_task_with_only_errors_is_not_queued_for_auto_retry(
coordinator: SyncCoordinator, monkeypatch: pytest.MonkeyPatch
) -> None:
task = coordinator.config.tasks[0]
coordinator._on_finished(task.id, SyncResult(errors=["Zugriff verweigert"]))
assert task.id not in coordinator._retry_tasks
queued = []
monkeypatch.setattr(coordinator, "enqueue", queued.append)
coordinator._check_retries()
assert queued == []
def test_retry_max_attempts_cap(coordinator: SyncCoordinator, monkeypatch: pytest.MonkeyPatch) -> None:
task = coordinator.config.tasks[0]
coordinator._retry_tasks[task.id] = []
coordinator._retry_attempts[task.id] = 5
queued = []
monkeypatch.setattr(coordinator, "enqueue", queued.append)
coordinator._check_retries()
assert queued == []
def test_start_resets_stale_progress_before_worker_starts( def test_start_resets_stale_progress_before_worker_starts(
@@ -137,3 +161,17 @@ def test_stop_persists_running_task_and_queue_for_restart(coordinator: SyncCoord
assert coordinator.config.settings.paused is True assert coordinator.config.settings.paused is True
assert coordinator.config.settings.pending_queue == [task1.id, task2.id] assert coordinator.config.settings.pending_queue == [task1.id, task2.id]
def test_enqueue_all_unpauses_and_runs(coordinator: SyncCoordinator) -> None:
from types import SimpleNamespace
coordinator.set_paused(True)
workers = []
coordinator.pool = SimpleNamespace(start=workers.append)
coordinator.enqueue_all()
assert not coordinator.config.settings.paused
assert len(workers) == 1
assert coordinator.running_task_id == coordinator.config.tasks[0].id
+9 -1
View File
@@ -3,9 +3,17 @@ from pathlib import Path
def test_installer_launches_admin_application_with_elevated_setup_token() -> None: def test_installer_launches_admin_application_with_elevated_setup_token() -> None:
script = Path("installer/SyncVito.iss").read_text(encoding="utf-8") script = Path("installer/SyncVito.iss").read_text(encoding="utf-8")
run_entries = [line for line in script.splitlines() if line.startswith("Filename:")] run_section = script.split("[Run]")[1].split("[")[0] if "[Run]" in script else ""
run_entries = [line for line in run_section.splitlines() if line.startswith("Filename:")]
assert len(run_entries) == 2 assert len(run_entries) == 2
assert all("runascurrentuser" in entry for entry in run_entries) assert all("runascurrentuser" in entry for entry in run_entries)
assert "postinstall" in run_entries[0] assert "postinstall" in run_entries[0]
assert 'Parameters: "--updated"' in run_entries[1] assert 'Parameters: "--updated"' in run_entries[1]
def test_installer_cleans_up_scheduled_task_on_uninstall() -> None:
script = Path("installer/SyncVito.iss").read_text(encoding="utf-8")
uninstall_section = script.split("[UninstallRun]")[1].split("[")[0] if "[UninstallRun]" in script else ""
assert "schtasks.exe" in uninstall_section
assert "{#MyAppName}" in uninstall_section
+24
View File
@@ -269,3 +269,27 @@ def test_pause_and_resume_continues_where_interrupted(tmp_path: Path) -> None:
assert (target / "a.txt").exists() assert (target / "a.txt").exists()
assert (target / "b.txt").exists() assert (target / "b.txt").exists()
assert (target / "c.txt").exists() assert (target / "c.txt").exists()
def test_concurrently_deleted_source_file_is_skipped(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
source = tmp_path / "source"
target = tmp_path / "target"
source.mkdir()
target.mkdir()
(source / "ephemeral.txt").write_text("wird gelöscht")
task = SyncTask(name="Transient", source=str(source), target=str(target))
engine = _engine(tmp_path)
# Simuliere, dass die Datei kurz vor der Ausführung gelöscht wurde
def delete_before_execute(operation, result):
if operation.source and operation.source.name == "ephemeral.txt":
operation.source.unlink(missing_ok=True)
return SyncEngine._execute(operation, result)
monkeypatch.setattr(engine, "_execute", delete_before_execute)
result = engine.synchronize(task)
assert result.successful
assert result.skipped == 1
assert not result.errors
assert not (target / "ephemeral.txt").exists()
+1 -1
View File
@@ -1 +1 @@
1.0.10 1.0.13