Robuste Darktable-Synchronisation: sequenzieller Ablauf, Versions- und Concurrent-Schutz
- Race Condition behoben: Pre-Sync wird vollstaendig abgewartet bevor Darktable startet - Post-Sync nach Schliessen von Darktable eingefuehrt (bisher fehlend) - .env aus festem Pfad ~/.config/darktable-sync/.env geladen (nicht mehr relativ) - Server-Erreichbarkeit per SSH statt ping (Firewall-sicher) - Darktable-Versionscheck (Major.Minor) vor Download mit Abbruch bei Konflikt - DB-Backup vor jedem Download (library.db.bak, data.db.bak) - sync_pending-Marker bei Offline/Fehler, Hinweis beim naechsten Start - darktable.active-Marker auf Server fuer Concurrent-Erkennung - Lock-Dateien vom Sync ausgeschlossen - systemd-Timer entfernt, Service bleibt als manueller Trigger - Gemeinsame Hilfsfunktionen in darktable_common.sh extrahiert - 20 BATS-Tests mit vollstaendigem Stub-System ohne GUI-Dialoge Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
load helpers/setup
|
||||
|
||||
SYNC_SCRIPT="$BATS_TEST_DIRNAME/../scripts/darktable_sync.sh"
|
||||
|
||||
setup() {
|
||||
create_valid_env
|
||||
mkdir -p "$HOME/.config/darktable"
|
||||
touch "$HOME/.config/darktable/library.db"
|
||||
touch "$HOME/.config/darktable/data.db"
|
||||
mkdir -p "$HOME/Pictures"
|
||||
export DISPLAY=:99
|
||||
}
|
||||
|
||||
@test "sync_pending wird gesetzt wenn Server nicht erreichbar" {
|
||||
run_with_stubs env SSH_STUB_FAIL=1 bash "$SYNC_SCRIPT"
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f "$CONFIG_DIR/sync_pending" ]
|
||||
}
|
||||
|
||||
@test "sync_pending wird entfernt bei erfolgreichem Sync" {
|
||||
touch "$CONFIG_DIR/sync_pending"
|
||||
run_with_stubs env SSH_STUB_FAIL=0 bash "$SYNC_SCRIPT"
|
||||
[ "$status" -eq 0 ]
|
||||
[ ! -f "$CONFIG_DIR/sync_pending" ]
|
||||
}
|
||||
|
||||
@test "sync_pending wird gesetzt wenn rsync fehlschlaegt" {
|
||||
run_with_stubs env SSH_STUB_FAIL=0 RSYNC_STUB_FAIL=1 bash "$SYNC_SCRIPT"
|
||||
[ "$status" -eq 1 ]
|
||||
[ -f "$CONFIG_DIR/sync_pending" ]
|
||||
}
|
||||
|
||||
@test "DB-Backup wird vor Download erstellt" {
|
||||
run_with_stubs env SSH_STUB_FAIL=0 bash "$SYNC_SCRIPT"
|
||||
[ "$status" -eq 0 ]
|
||||
[ -f "$HOME/.config/darktable/library.db.bak" ]
|
||||
[ -f "$HOME/.config/darktable/data.db.bak" ]
|
||||
}
|
||||
|
||||
@test "Versionskonflikt: gleiche Major.Minor gibt kein Exit 1" {
|
||||
run_with_stubs env SSH_STUB_FAIL=0 SSH_STUB_OUTPUT="this is darktable 5.0.1" \
|
||||
DARKTABLE_STUB_VERSION="5.0.1" bash "$SYNC_SCRIPT"
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "Versionskonflikt: andere Major.Minor gibt Exit 1" {
|
||||
run_with_stubs env SSH_STUB_FAIL=0 SSH_STUB_OUTPUT="this is darktable 4.8.0" \
|
||||
DARKTABLE_STUB_VERSION="5.0.0" bash "$SYNC_SCRIPT"
|
||||
[ "$status" -eq 1 ]
|
||||
[ -f "$CONFIG_DIR/sync_pending" ]
|
||||
}
|
||||
|
||||
@test "Lockfile wird nach Abschluss entfernt" {
|
||||
run_with_stubs env SSH_STUB_FAIL=0 bash "$SYNC_SCRIPT"
|
||||
[ "$status" -eq 0 ]
|
||||
[ ! -f "/tmp/darktable_sync.sh.lock" ]
|
||||
}
|
||||
Reference in New Issue
Block a user