Code-Vereinfachung: Redundanzen entfernen und Wiederverwendung verbessern

- log() Funktion in darktable_common.sh ausgelagert (war doppelt vorhanden)
- ssh_server() Hilfsfunktion für wiederholte SSH-Aufrufe mit konsistenten Optionen
- ssh_server() nutzen statt inline SSH-Befehle in darktable_sync.sh und darktable_wrapper.sh
- Reduzierung von SSH-Optionswiederbholungen (ConnectTimeout, BatchMode, Port)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-19 19:45:11 +02:00
parent 6a6ce52cf9
commit 46664ab3b6
3 changed files with 15 additions and 25 deletions
+2 -10
View File
@@ -15,10 +15,6 @@ validate_config
export DISPLAY="${DISPLAY:-:0}"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
}
count_synced_files() {
local log_file="$1" direction="$2" count=0
case "$direction" in
@@ -59,17 +55,13 @@ if [ "$SHOW_NOTIFY_START_STOP" = true ]; then
notify-send "Darktable Sync" "Sync gestartet..." -t 3000
fi
ACTIVE=$(ssh -o ConnectTimeout=5 -o BatchMode=yes \
-p "$SERVER_SSH_PORT" "$SERVER_USER@$SERVER_IP" \
"cat '$SERVER_DB_DIR/darktable.active' 2>/dev/null || true")
ACTIVE=$(ssh_server "cat '$SERVER_DB_DIR/darktable.active' 2>/dev/null || true")
if [ -n "$ACTIVE" ]; then
notify-send "Darktable Sync Warnung" \
"Darktable laueft moeglicherweise auf: $ACTIVE" -u normal -t 10000
fi
SERVER_VERSION=$(ssh -o ConnectTimeout=5 -o BatchMode=yes \
-p "$SERVER_SSH_PORT" "$SERVER_USER@$SERVER_IP" \
"cat '$SERVER_DB_DIR/darktable_version' 2>/dev/null || true")
SERVER_VERSION=$(ssh_server "cat '$SERVER_DB_DIR/darktable_version' 2>/dev/null || true")
LOCAL_VERSION=$(darktable --version 2>&1 | head -1)