non-blocking logic
This commit is contained in:
@@ -43,6 +43,8 @@ do
|
||||
this_state="$value"
|
||||
|
||||
if [ "$this_state" = "playing" ] && [ "$this_action" = "rungame" ]; then
|
||||
# We wrap the whole operation in ( ) & to background the entire sequence
|
||||
(
|
||||
log "INFO" "Game Started: $(basename "$this_game_path")"
|
||||
|
||||
filename=$(basename "$this_save_path")
|
||||
@@ -55,25 +57,29 @@ do
|
||||
if [ "$local_size" -lt "$remote_size" ]; then
|
||||
log "WARN" "Cloud save LARGER. Restoring..."
|
||||
mkdir -p "$(dirname "$this_backup_path")"
|
||||
# Fixed: backup-dir needs to be a directory
|
||||
rclone copyto "$remote_full" "$this_save_path" --backup-dir "$(dirname "$this_backup_path")"
|
||||
else
|
||||
log "INFO" "Local save safe. Updating..."
|
||||
rclone update "$remote_full" "$this_save_path"
|
||||
fi
|
||||
|
||||
# FIX: Added -m flag
|
||||
# Signal that sync is done
|
||||
mosquitto_pub -h 127.0.0.1 -p 1883 -t "$TOPIC" -m "SaveContinue=0"
|
||||
) &
|
||||
log "DEBUG" "Sync process backgrounded for Start Game."
|
||||
|
||||
elif [ "$this_state" = "endgame" ]; then
|
||||
(
|
||||
log "INFO" "Game Ended. Syncing..."
|
||||
rclone update "$this_save_path" "$REMOTE_BASE/$this_system_id/"
|
||||
log "INFO" "Sync Complete."
|
||||
|
||||
mosquitto_pub -h 127.0.0.1 -p 1883 -t "$TOPIC" -m "SaveContinue=0"
|
||||
) &
|
||||
log "DEBUG" "Sync process backgrounded for End Game."
|
||||
fi
|
||||
|
||||
# Reset variables
|
||||
# Reset variables immediately so the loop is ready for the next line
|
||||
this_system_id=""; this_game_path=""; this_save_path=""; this_action=""; this_backup_path=""
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user