feat: Update-Prüfung beim Start und Versions-Endpunkt

- App prüft version.json beim Start (nur exportierte Desktop-Builds)
- Dialog, Download mit SHA-256-Prüfung, Installation je Plattform
- manueller Menüpunkt, übersprungene Version in user://update.cfg
- Endpunkt unter rinkplanner.programmschmiede.de/version.json
- tools/publish_version.sh und Doku in docs/updates.md
- Version 0.2.0
This commit is contained in:
torsten 2026-11-11 18:26:11 +01:00
parent b75953e97f
commit 54e1c5dc34
23 changed files with 1378 additions and 12 deletions

View file

@ -66,8 +66,8 @@ application/modify_resources=true
application/icon="res://assets/icons/app_icon.png"
application/console_wrapper_icon=""
application/icon_interpolation=4
application/file_version="0.1.0.0"
application/product_version="0.1.0.0"
application/file_version="0.2.0.0"
application/product_version="0.2.0.0"
application/company_name=""
application/product_name="Rinkplanner"
application/file_description="2D-Whiteboard für Eiskunstlauf"
@ -118,8 +118,8 @@ application/icon_interpolation=4
application/bundle_identifier="de.rinkplanner.app"
application/signature=""
application/app_category="Education"
application/short_version=""
application/version=""
application/short_version="0.2.0"
application/version="0.2.0"
application/copyright=""
application/copyright_localized={}
application/min_macos_version_x86_64="11.00"
@ -243,8 +243,8 @@ keystore/debug_password=""
keystore/release=""
keystore/release_user=""
keystore/release_password=""
version/code=1
version/name="0.1.0"
version/code=2
version/name="0.2.0"
package/unique_name="de.rinkplanner.app"
package/name="Rinkplanner"
package/signed=true

View file

@ -15,6 +15,7 @@ compatibility/default_parent_skeleton_in_mesh_instance_3d=true
[application]
config/name="Rinkplanner"
config/version="0.2.0"
run/main_scene="res://scenes/whiteboard/whiteboard.tscn"
config/features=PackedStringArray("4.7", "Forward Plus")
config/icon="res://assets/icons/app_icon.png"

View file

@ -1952,6 +1952,22 @@ unique_name_in_owner = true
layout_mode = 2
text = "Rechte an Kür und Musik bestätigt"
[node name="UpdateDialog" type="ConfirmationDialog" parent="."]
unique_name_in_owner = true
title = "Update verfügbar"
size = Vector2i(640, 420)
ok_button_text = "Jetzt aktualisieren"
cancel_button_text = "Später"
[node name="UpdateText" type="Label" parent="UpdateDialog"]
unique_name_in_owner = true
offset_left = 16.0
offset_top = 12.0
offset_right = 624.0
offset_bottom = 350.0
text = ""
autowrap_mode = 2
[node name="HubConflictDialog" type="ConfirmationDialog" parent="."]
unique_name_in_owner = true
title = "Kür bereits vorhanden"

View file

@ -10,7 +10,7 @@ extends RefCounted
const DEFAULT_TIMEOUT_MSEC := 30000
const TRANSFER_TIMEOUT_MSEC := 300000
const POLL_DELAY_MSEC := 5
const USER_AGENT := "Rinkplanner/0.1 (Godot)"
const USER_AGENT := "Rinkplanner (Godot)"
var last_error: String = ""

View file

@ -0,0 +1,115 @@
class_name UpdateClient
extends RefCounted
## Blocking update client. Like [HubClient] it runs on a worker thread; the
## controller polls the thread and updates the UI on the main thread.
##
## The payload is validated with [UpdateInfo]. Downloads are only accepted from
## HTTPS URLs and, when the endpoint provides a SHA-256, verified before the
## installer is started.
const REQUEST_TIMEOUT_MSEC := 20000
const DOWNLOAD_TIMEOUT_MSEC := 600000
## The installers are ~70 MB today; this is only a guard against a broken
## endpoint filling the disk.
const MAX_DOWNLOAD_BYTES := 512 * 1024 * 1024
const DOWNLOAD_DIR := "user://updates"
var last_error: String = ""
var _http := CloudHttp.new()
## Fetches and validates the endpoint document.
func check(endpoint: String) -> Dictionary:
last_error = ""
if not endpoint.begins_with("https://"):
last_error = "Die Update-Adresse muss HTTPS verwenden."
return {}
var response := _http.request(
HTTPClient.METHOD_GET,
endpoint,
PackedStringArray(["Accept: application/json"]),
PackedByteArray(),
REQUEST_TIMEOUT_MSEC
)
if response.is_empty():
last_error = _http.last_error
return {}
var status := int(response.get("status", 0))
if status != 200:
last_error = "Der Update-Server antwortet mit HTTP %d." % status
return {}
var data: Variant = CloudHttp.json_parse(response.get("body", PackedByteArray()))
var info := UpdateInfo.parse_payload(data)
if info.is_empty():
last_error = "Der Update-Server hat eine ungültige Antwort geliefert."
return {}
return info
## Downloads one installer to user://updates and verifies its SHA-256.
func download(url: String, expected_sha: String, file_name: String) -> Dictionary:
last_error = ""
if not url.begins_with("https://"):
last_error = "Die Download-Adresse muss HTTPS verwenden."
return {}
var target_name := _safe_file_name(file_name)
var response := _http.request(
HTTPClient.METHOD_GET,
url,
PackedStringArray(["Accept: application/octet-stream"]),
PackedByteArray(),
DOWNLOAD_TIMEOUT_MSEC
)
if response.is_empty():
last_error = _http.last_error
return {}
var status := int(response.get("status", 0))
if status != 200:
last_error = "Der Update-Download antwortet mit HTTP %d." % status
return {}
var payload: PackedByteArray = response.get("body", PackedByteArray())
if payload.is_empty():
last_error = "Der Update-Download hat keine Daten geliefert."
return {}
if payload.size() > MAX_DOWNLOAD_BYTES:
last_error = "Die Update-Datei ist unerwartet groß."
return {}
var target := DOWNLOAD_DIR.path_join(target_name)
var directory_error := DirAccess.make_dir_recursive_absolute(DOWNLOAD_DIR)
if directory_error != OK and not DirAccess.dir_exists_absolute(DOWNLOAD_DIR):
last_error = "Der Update-Ordner ist nicht beschreibbar."
return {}
var file := FileAccess.open(target, FileAccess.WRITE)
if file == null:
last_error = "Die Update-Datei konnte nicht gespeichert werden."
return {}
file.store_buffer(payload)
file.close()
if not expected_sha.is_empty():
var actual := FileAccess.get_sha256(target).to_lower()
if actual != expected_sha.to_lower():
_remove(target)
last_error = "Die Prüfsumme der Update-Datei stimmt nicht."
return {}
return {"path": target, "bytes": payload.size()}
static func _safe_file_name(value: String) -> String:
var name := value.strip_edges()
var query := name.find("?")
if query >= 0:
name = name.substr(0, query)
for character: String in ["/", "\\", ":", "*", "?", "\"", "<", ">", "|"]:
name = name.replace(character, "")
if name.is_empty() or name == "." or name == "..":
name = "rinkplanner-update"
return name
static func _remove(path: String) -> void:
if FileAccess.file_exists(path):
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))

View file

@ -0,0 +1 @@
uid://ba4nt20p6hrer

View file

@ -0,0 +1,167 @@
class_name UpdateInfo
extends RefCounted
## Pure helpers for the update check: version comparison, endpoint payload
## validation, platform selection and the skipped-version state.
##
## The endpoint is a static JSON document served over HTTPS. Example:
## {
## "version": "0.2.0",
## "released": "2026-11-11",
## "notes": "Kurze Beschreibung der Neuerungen.",
## "downloads": {
## "macos": {"url": "...", "sha256": "...", "size": 71286441},
## "windows": {"url": "...", "sha256": "...", "size": 35000000}
## }
## }
const DEFAULT_ENDPOINT := "https://rinkplanner.programmschmiede.de/version.json"
const STATE_PATH := "user://update.cfg"
const VERSION_SETTING := "application/config/version"
## Version of the running build. The value comes from project.godot and is
## mirrored into the export presets for the platform metadata.
static func current_version() -> String:
return str(ProjectSettings.get_setting(VERSION_SETTING, "0.0.0")).strip_edges()
## Numeric version segments. Pre-release suffixes and leading "v" are ignored,
## so "v0.2.0-beta" compares like "0.2.0".
static func parse_version(text: String) -> PackedInt32Array:
var cleaned := text.strip_edges()
if cleaned.begins_with("v") or cleaned.begins_with("V"):
cleaned = cleaned.substr(1)
var parts := PackedInt32Array()
for token: String in cleaned.split("."):
var digits := ""
for index: int in range(token.length()):
var code := token.unicode_at(index)
if code < 48 or code > 57:
break
digits += token.substr(index, 1)
if digits.is_empty():
break
parts.append(int(digits))
while parts.size() > 1 and parts[parts.size() - 1] == 0:
parts.remove_at(parts.size() - 1)
return parts
## Returns -1, 0 or 1 like a comparator.
static func compare_versions(left: String, right: String) -> int:
var a := parse_version(left)
var b := parse_version(right)
var count := maxi(a.size(), b.size())
for index: int in range(count):
var value_a := a[index] if index < a.size() else 0
var value_b := b[index] if index < b.size() else 0
if value_a < value_b:
return -1
if value_a > value_b:
return 1
return 0
static func is_newer(candidate: String, current: String) -> bool:
return compare_versions(candidate, current) > 0
## Platform key used in the endpoint's "downloads" object.
static func platform_key(os_name: String = "") -> String:
var name := os_name if not os_name.is_empty() else OS.get_name()
match name:
"macOS", "OSX", "MacOS":
return "macos"
"Windows":
return "windows"
"Linux":
return "linux"
"Android":
return "android"
_:
return name.to_lower()
## Validates the endpoint response. Returns an empty dictionary when the
## payload is not usable, so callers can show a single error message.
static func parse_payload(data: Variant) -> Dictionary:
if not data is Dictionary:
return {}
var dict: Dictionary = data
var version := str(dict.get("version", "")).strip_edges()
if parse_version(version).is_empty():
return {}
var downloads: Variant = dict.get("downloads", {})
if not downloads is Dictionary or (downloads as Dictionary).is_empty():
return {}
return {
"version": version,
"released": str(dict.get("released", "")).strip_edges(),
"notes": _notes_text(dict.get("notes", "")),
"downloads": downloads,
}
## Download entry for one platform. Requires HTTPS and a non-empty URL.
static func download_for(info: Dictionary, platform: String) -> Dictionary:
var downloads: Variant = info.get("downloads", {})
if not downloads is Dictionary:
return {}
var entry: Variant = (downloads as Dictionary).get(platform, null)
if not entry is Dictionary:
return {}
var dict: Dictionary = entry
var url := str(dict.get("url", "")).strip_edges()
if not url.begins_with("https://"):
return {}
return {
"url": url,
"sha256": str(dict.get("sha256", "")).strip_edges().to_lower(),
"size": int(dict.get("size", 0)),
}
## Turns "2026-11-11" into "11.11.2026"; other values stay unchanged.
static func format_date(value: String) -> String:
var text := value.strip_edges()
if text.length() != 10:
return text
if text.substr(4, 1) != "-" or text.substr(7, 1) != "-":
return text
var year := text.substr(0, 4)
var month := text.substr(5, 2)
var day := text.substr(8, 2)
if not year.is_valid_int() or not month.is_valid_int() or not day.is_valid_int():
return text
return "%s.%s.%s" % [day, month, year]
static func load_skipped_version() -> String:
var config := ConfigFile.new()
if config.load(STATE_PATH) != OK:
return ""
return str(config.get_value("update", "skipped_version", "")).strip_edges()
static func remember_skipped_version(version: String) -> void:
var config := ConfigFile.new()
config.load(STATE_PATH)
config.set_value("update", "skipped_version", version.strip_edges())
config.save(STATE_PATH)
static func clear_skipped_version() -> void:
if FileAccess.file_exists(STATE_PATH):
DirAccess.remove_absolute(ProjectSettings.globalize_path(STATE_PATH))
static func _notes_text(value: Variant) -> String:
if value is Array:
var lines := PackedStringArray()
for item: Variant in value:
var line := str(item).strip_edges()
if not line.is_empty():
lines.append(line)
return "\n".join(lines)
return str(value).strip_edges()

View file

@ -0,0 +1 @@
uid://0twlni2uxvlb

View file

@ -0,0 +1,46 @@
class_name UpdateJob
extends RefCounted
## One blocking update operation for a worker thread. Mirrors [HubJob]: the
## controller owns the thread and reads [member result]/[member error] after it
## has finished.
enum Task {
CHECK,
DOWNLOAD,
}
var task: Task = Task.CHECK
var payload: Dictionary = {}
var result: Dictionary = {}
var error: String = ""
var progress: String = ""
func run(config: Dictionary) -> void:
error = ""
result = {}
progress = ""
var client := UpdateClient.new()
match task:
Task.CHECK:
progress = "Suche nach Updates …"
result = client.check(
str(config.get("endpoint", UpdateInfo.DEFAULT_ENDPOINT))
)
Task.DOWNLOAD:
progress = "Lade Update …"
result = client.download(
str(payload.get("url", "")),
str(payload.get("sha256", "")),
str(payload.get("file_name", "rinkplanner-update"))
)
_:
error = "Unbekannte Update-Aktion."
if result.is_empty() and error.is_empty():
error = client.last_error
if error.is_empty():
error = "Der Update-Server hat keine Daten geliefert."
progress = ""

View file

@ -0,0 +1 @@
uid://41poctrntwic

View file

@ -28,6 +28,7 @@ enum FileAction {
SYNC_SETTINGS,
MANAGE_ROUTINES,
HUB_OPEN,
UPDATE_CHECK,
}
const DEFAULT_SPEED_MPS := 4.3
@ -120,10 +121,18 @@ const COMPACT_LAYOUT_WIDTH := 1390.0
## are normal (output latency, dropped frames); only larger drift is corrected.
const MUSIC_DRIFT_TOLERANCE_SECONDS := 0.35
const MAX_MUSIC_FILE_BYTES := 64 * 1024 * 1024
const UPDATE_FILE_NAMES := {
"macos": "rinkplanner-setup.dmg",
"windows": "rinkplanner-setup.exe",
"linux": "rinkplanner-setup",
}
## Tests disable these before adding the scene to the tree.
@export var restore_autosave: bool = true
@export var autosave_enabled: bool = true
## Automatic update check on start. Only exported desktop builds check; the
## editor and the headless tests stay offline.
@export var check_for_updates: bool = true
@onready var rink_canvas: RinkCanvas = %RinkCanvas
@onready var title_label: Label = %Title
@ -254,6 +263,8 @@ const MAX_MUSIC_FILE_BYTES := 64 * 1024 * 1024
@onready var hub_account_value: Label = %HubAccountValue
@onready var hub_connect_button: Button = %HubConnectButton
@onready var hub_dialog: AcceptDialog = %HubDialog
@onready var update_dialog: ConfirmationDialog = %UpdateDialog
@onready var update_text: Label = %UpdateText
@onready var hub_dialog_account: Label = %HubDialogAccount
@onready var hub_search_edit: LineEdit = %HubSearchEdit
@onready var hub_search_button: Button = %HubSearchButton
@ -354,6 +365,11 @@ var _hub_job: HubJob
var _hub_running: bool = false
var _hub_items: Array[Dictionary] = []
var _hub_pending_download: Dictionary = {}
var _update_thread: Thread
var _update_job: UpdateJob
var _update_running: bool = false
var _update_available: Dictionary = {}
var _update_manual: bool = false
var _cleanup_candidates: Array = []
var _pending_delete_name: String = ""
var _pending_rename_name: String = ""
@ -529,6 +545,8 @@ func _ready() -> void:
)
cloud_auth_dialog.confirmed.connect(_on_cloud_auth_confirmed)
cloud_auth_dialog.canceled.connect(_on_cloud_auth_canceled)
update_dialog.confirmed.connect(_on_update_confirmed)
update_dialog.canceled.connect(_on_update_canceled)
label_button.pressed.connect(_open_label_dialog)
multi_select_button.toggled.connect(_on_multi_select_toggled)
group_sequence_button.pressed.connect(_on_group_sequence_pressed)
@ -556,6 +574,9 @@ func _ready() -> void:
if not (restore_autosave and _restore_session()):
new_routine()
if check_for_updates:
_start_update_check.call_deferred(false)
func get_routine() -> Routine:
return _routine
@ -3861,6 +3882,7 @@ func _process(delta: float) -> void:
_poll_sync_thread()
_poll_oauth_thread()
_poll_hub_thread()
_poll_update_thread()
if _sync_running and _sync_job != null and not _sync_job.progress.is_empty():
status_label.text = "Sync: " + _sync_job.progress
@ -5249,6 +5271,8 @@ func _setup_file_menu() -> void:
popup.add_item("Jetzt synchronisieren", FileAction.SYNC_NOW)
popup.add_item("Sync-Einstellungen…", FileAction.SYNC_SETTINGS)
popup.add_item("Küren verwalten…", FileAction.MANAGE_ROUTINES)
popup.add_separator()
popup.add_item("Nach Updates suchen…", FileAction.UPDATE_CHECK)
popup.id_pressed.connect(_on_file_menu_pressed)
@ -5274,6 +5298,8 @@ func _on_file_menu_pressed(action: int) -> void:
_open_routine_manager()
FileAction.HUB_OPEN:
_open_hub_dialog()
FileAction.UPDATE_CHECK:
_start_update_check(true)
func _set_routine(routine: Routine, path: String) -> void:
@ -8013,3 +8039,317 @@ func _update_status() -> void:
_:
hint = "Tippen: Sprung setzen · Element-Button: Kürzel, Kombination"
status_label.text = "%s | %s" % [text, hint]
# --- Update check -----------------------------------------------------------
func _start_update_check(manual: bool) -> void:
if _update_running:
if manual:
_show_message("Es läuft bereits eine Update-Prüfung.")
return
if not manual and not _update_check_allowed():
return
_update_manual = manual
if manual:
status_label.text = "Suche nach Updates …"
_start_update_job(UpdateJob.Task.CHECK)
## Only exported desktop builds check automatically; the editor and the
## headless tests must not touch the network on start.
func _update_check_allowed() -> bool:
if not OS.has_feature("template") or OS.has_feature("web"):
return false
return UpdateInfo.platform_key() in ["macos", "windows", "linux"]
func _start_update_job(task: UpdateJob.Task, payload: Dictionary = {}) -> void:
_update_job = UpdateJob.new()
_update_job.task = task
_update_job.payload = payload
_update_thread = Thread.new()
var thread_error := _update_thread.start(
_update_job.run.bind({"endpoint": UpdateInfo.DEFAULT_ENDPOINT})
)
if thread_error != OK:
_update_thread = null
_update_job = null
_update_running = false
if _update_manual:
_show_message(
"Update-Prüfung konnte nicht gestartet werden (Fehler %d)."
% thread_error
)
else:
push_warning("Update check thread failed: %d" % thread_error)
return
_update_running = true
func _poll_update_thread() -> void:
if _update_thread == null or _update_thread.is_alive():
return
_update_thread.wait_to_finish()
_update_thread = null
_update_running = false
var job := _update_job
_update_job = null
if job == null:
return
_finish_update_job(job)
func _finish_update_job(job: UpdateJob) -> void:
if not job.error.is_empty():
_update_available = {}
if _update_manual:
status_label.text = "Update-Prüfung fehlgeschlagen."
_show_message("Update-Prüfung:\n\n" + job.error)
else:
push_warning("Update check failed: " + job.error)
return
match job.task:
UpdateJob.Task.CHECK:
_finish_update_check(job)
UpdateJob.Task.DOWNLOAD:
_finish_update_download(job)
_:
pass
func _finish_update_check(job: UpdateJob) -> void:
var info := job.result
var current := UpdateInfo.current_version()
var remote := str(info.get("version", "")).strip_edges()
if not UpdateInfo.is_newer(remote, current):
if _update_manual:
status_label.text = "Rinkplanner ist aktuell."
_show_message("Rinkplanner ist aktuell (Version %s)." % current)
return
var platform := UpdateInfo.platform_key()
var download := UpdateInfo.download_for(info, platform)
if download.is_empty():
if _update_manual:
status_label.text = "Kein Update für diese Plattform."
_show_message(
(
"Version %s ist verfügbar, aber für %s liegt keine "
+ "Update-Datei bereit."
) % [remote, OS.get_name()]
)
return
if not _update_manual and UpdateInfo.load_skipped_version() == remote:
return
_update_available = info.duplicate(true)
_update_available["download"] = download
_update_available["platform"] = platform
update_text.text = _update_dialog_text(_update_available, download, current)
update_dialog.popup_centered(Vector2i(640, 420))
func _update_dialog_text(
info: Dictionary,
download: Dictionary,
current: String
) -> String:
var remote := str(info.get("version", "")).strip_edges()
var lines := PackedStringArray([
"Rinkplanner %s ist verfügbar." % remote,
"Installiert: %s" % current,
])
var released := UpdateInfo.format_date(str(info.get("released", "")))
if not released.is_empty():
lines.append("Veröffentlicht: %s" % released)
var notes := str(info.get("notes", "")).strip_edges()
if not notes.is_empty():
lines.append("")
lines.append(notes)
var size := int(download.get("size", 0))
if size > 0:
lines.append("")
lines.append("Download: %.1f MB" % (float(size) / 1048576.0))
lines.append("")
lines.append(_update_install_hint(str(info.get("platform", ""))))
return "\n".join(lines)
func _update_install_hint(platform: String) -> String:
match platform:
"macos":
return (
"Nach der Bestätigung wird die neue App heruntergeladen, "
+ "geprüft und die aktuelle Installation ersetzt. Rinkplanner "
+ "startet danach neu."
)
"windows":
return (
"Nach der Bestätigung wird der Installer heruntergeladen und "
+ "gestartet. Rinkplanner beendet sich dafür."
)
"linux":
return (
"Nach der Bestätigung wird das Update heruntergeladen und "
+ "anschließend im Dateimanager geöffnet."
)
_:
return "Nach der Bestätigung wird das Update heruntergeladen."
func _on_update_confirmed() -> void:
if _update_available.is_empty() or _update_running:
return
var download: Dictionary = _update_available.get("download", {})
var version := str(_update_available.get("version", "")).strip_edges()
var platform := str(_update_available.get("platform", ""))
var file_name := str(UPDATE_FILE_NAMES.get(platform, "rinkplanner-update"))
status_label.text = "Update: Lade Rinkplanner %s …" % version
_start_update_job(UpdateJob.Task.DOWNLOAD, {
"url": str(download.get("url", "")),
"sha256": str(download.get("sha256", "")),
"file_name": file_name,
})
func _on_update_canceled() -> void:
if not _update_available.is_empty():
UpdateInfo.remember_skipped_version(
str(_update_available.get("version", ""))
)
_update_available = {}
status_label.text = "Update verschoben."
func _finish_update_download(job: UpdateJob) -> void:
var path := str(job.result.get("path", ""))
if path.is_empty():
_update_available = {}
status_label.text = "Update fehlgeschlagen."
_show_message("Das Update konnte nicht heruntergeladen werden.")
return
var version := str(_update_available.get("version", "")).strip_edges()
status_label.text = "Update: Installiere Rinkplanner %s …" % version
await get_tree().process_frame
var message := _install_update(path)
_update_available = {}
if not message.is_empty():
_show_message(message)
func _install_update(path: String) -> String:
match OS.get_name():
"macOS":
return _install_macos_update(path)
"Windows":
return _install_windows_update(path)
_:
return _open_update_folder(path)
## Mounts the DMG and replaces the running bundle in place. Falls back to
## opening the image when the copy is not possible (permissions, unbundled
## editor run).
func _install_macos_update(path: String) -> String:
var output: Array = []
var attach_code := OS.execute(
"/usr/bin/hdiutil",
["attach", "-nobrowse", "-readonly", path],
output,
true
)
if attach_code != 0:
OS.shell_open(path)
return (
"Das Update wurde heruntergeladen und im Finder geöffnet. Bitte "
+ "die App aus dem Image in den Programme-Ordner ziehen."
)
var mount := _find_mount_point(output)
var app_name := ""
if not mount.is_empty() and DirAccess.dir_exists_absolute(mount):
for entry: String in DirAccess.get_directories_at(mount):
if entry.ends_with(".app"):
app_name = entry
break
var target := _current_app_bundle()
if mount.is_empty() or app_name.is_empty() or target.is_empty():
if not mount.is_empty():
OS.execute("/usr/bin/hdiutil", ["detach", mount, "-quiet"], output, true)
OS.shell_open(path)
return (
"Das Update wurde heruntergeladen und im Finder geöffnet. Bitte "
+ "die App aus dem Image in den Programme-Ordner ziehen."
)
var source := mount.path_join(app_name)
var copy_output: Array = []
var copy_code := OS.execute(
"/usr/bin/ditto",
[source, target],
copy_output,
true
)
OS.execute("/usr/bin/hdiutil", ["detach", mount, "-quiet"], output, true)
if copy_code != 0:
OS.shell_open(path)
return (
"Das Update wurde heruntergeladen, konnte aber nicht automatisch "
+ "installiert werden. Das Image ist geöffnet; bitte die App "
+ "manuell ersetzen."
)
_remove_update_file(path)
OS.create_process("/usr/bin/open", ["-n", target])
_quit_after_update.call_deferred()
return ""
func _install_windows_update(path: String) -> String:
var global_path := ProjectSettings.globalize_path(path)
var pid := OS.create_process(global_path, [])
if pid <= 0:
OS.shell_open(global_path)
return (
"Der Installer wurde heruntergeladen und im Explorer geöffnet. "
+ "Bitte die Installation abschließen."
)
_quit_after_update.call_deferred()
return ""
func _open_update_folder(path: String) -> String:
var folder := ProjectSettings.globalize_path(path.get_base_dir())
OS.shell_open(folder)
return "Das Update wurde nach\n%s\nheruntergeladen." % folder
func _find_mount_point(output: Array) -> String:
for raw: Variant in output:
for line: String in str(raw).split("\n"):
var fields := line.split("\t")
if fields.size() < 3:
continue
var candidate := fields[fields.size() - 1].strip_edges()
if candidate.begins_with("/Volumes/"):
return candidate
return ""
static func _current_app_bundle() -> String:
var executable := OS.get_executable_path()
var marker := executable.find(".app/")
var bundle := ""
if marker >= 0:
bundle = executable.substr(0, marker + 4)
elif executable.ends_with(".app"):
bundle = executable
if bundle.is_empty() or not DirAccess.dir_exists_absolute(bundle):
return ""
return bundle
func _quit_after_update() -> void:
await get_tree().create_timer(1.0).timeout
get_tree().quit()
static func _remove_update_file(path: String) -> void:
if FileAccess.file_exists(path):
DirAccess.remove_absolute(ProjectSettings.globalize_path(path))

View file

@ -0,0 +1,26 @@
extends SceneTree
## Manual check against the live update endpoint. Not part of the test suite.
## godot --headless --path rinkplanner --script res://tests/manual/check_update.gd
func _init() -> void:
_run.call_deferred()
func _run() -> void:
print("Installiert: ", UpdateInfo.current_version())
print("Endpunkt: ", UpdateInfo.DEFAULT_ENDPOINT)
var client := UpdateClient.new()
var info := client.check(UpdateInfo.DEFAULT_ENDPOINT)
if info.is_empty():
printerr("Update-Prüfung fehlgeschlagen: ", client.last_error)
quit(1)
return
var remote := str(info.get("version", ""))
print("Veröffentlicht: ", remote)
print("Neuer: ", UpdateInfo.is_newer(remote, UpdateInfo.current_version()))
var platform := UpdateInfo.platform_key()
var download := UpdateInfo.download_for(info, platform)
print("Plattform: ", platform)
print("Download: ", download)
quit(0)

View file

@ -0,0 +1 @@
uid://c45knw4nvdwuo

View file

@ -0,0 +1,227 @@
extends SceneTree
## Headless tests for the update check: version comparison, endpoint payload
## validation, platform selection, skipped-version state and the dialog wiring.
## No network access is required.
const WhiteboardScene := preload("res://scenes/whiteboard/whiteboard.tscn")
var _assertions: int = 0
var _failures: PackedStringArray = PackedStringArray()
func _init() -> void:
_run.call_deferred()
func _run() -> void:
_test_current_version()
_test_version_comparison()
_test_platform_keys()
_test_payload_parsing()
_test_download_selection()
_test_date_format()
_test_skipped_state()
await _test_controller_wiring()
UpdateInfo.clear_skipped_version()
_finish()
func _test_current_version() -> void:
var configured := str(
ProjectSettings.get_setting("application/config/version", "")
).strip_edges()
_check(not configured.is_empty(), "project.godot setzt eine Version")
_check(
UpdateInfo.current_version() == configured,
"die Laufzeitversion kommt aus project.godot"
)
_check(
not UpdateInfo.parse_version(UpdateInfo.current_version()).is_empty(),
"die Laufzeitversion ist numerisch"
)
func _test_version_comparison() -> void:
_check(UpdateInfo.is_newer("0.2.0", "0.1.0"), "0.2.0 ist neuer als 0.1.0")
_check(
not UpdateInfo.is_newer("0.1.0", "0.1.0"),
"gleiche Versionen sind nicht neuer"
)
_check(
not UpdateInfo.is_newer("0.1.0", "0.2.0"),
"ältere Versionen sind nicht neuer"
)
_check(
UpdateInfo.is_newer("0.10.0", "0.9.9"),
"Versionen werden numerisch und nicht lexikografisch verglichen"
)
_check(
UpdateInfo.compare_versions("1.0", "1.0.0") == 0,
"fehlende Segmente zählen als Null"
)
_check(
UpdateInfo.is_newer("v0.2.0-beta", "0.1.9"),
"v-Präfix und Vorab-Suffix werden ignoriert"
)
_check(
UpdateInfo.parse_version("0.2.0") == PackedInt32Array([0, 2]),
"abschließende Nullen werden entfernt"
)
func _test_platform_keys() -> void:
_check(UpdateInfo.platform_key("macOS") == "macos", "macOS wird erkannt")
_check(UpdateInfo.platform_key("Windows") == "windows", "Windows wird erkannt")
_check(UpdateInfo.platform_key("Linux") == "linux", "Linux wird erkannt")
_check(UpdateInfo.platform_key("Android") == "android", "Android wird erkannt")
func _test_payload_parsing() -> void:
var payload := {
"version": "0.2.0",
"released": "2026-11-11",
"notes": "Neu: Update-Prüfung.",
"downloads": {
"macos": {"url": "https://example.org/rinkplanner.dmg", "size": 100},
},
}
var info := UpdateInfo.parse_payload(payload)
_check(str(info.get("version", "")) == "0.2.0", "die Version wird gelesen")
_check(
str(info.get("notes", "")) == "Neu: Update-Prüfung.",
"die Notizen werden gelesen"
)
_check(
info.get("downloads") is Dictionary,
"die Download-Liste bleibt erhalten"
)
_check(
UpdateInfo.parse_payload({"version": "abc"}).is_empty(),
"eine nicht numerische Version wird abgelehnt"
)
_check(
UpdateInfo.parse_payload({"version": "0.2.0"}).is_empty(),
"eine fehlende Download-Liste wird abgelehnt"
)
_check(UpdateInfo.parse_payload("kaputt").is_empty(), "Text wird abgelehnt")
_check(
UpdateInfo.parse_payload({
"version": "0.2.0",
"downloads": {"macos": {"url": "https://example.org/a.dmg"}},
"notes": ["Zeile 1", "Zeile 2"],
}).get("notes") == "Zeile 1\nZeile 2",
"Notizen dürfen als Liste kommen"
)
func _test_download_selection() -> void:
var info := {
"downloads": {
"macos": {
"url": "https://example.org/rinkplanner.dmg",
"sha256": "ABCDEF",
"size": 123,
},
"windows": {"url": "http://example.org/rinkplanner.exe"},
},
}
var mac := UpdateInfo.download_for(info, "macos")
_check(not mac.is_empty(), "ein HTTPS-Download wird ausgewählt")
_check(str(mac.get("sha256", "")) == "abcdef", "die Prüfsumme wird normalisiert")
_check(int(mac.get("size", 0)) == 123, "die Größe wird übernommen")
_check(
UpdateInfo.download_for(info, "windows").is_empty(),
"HTTP-Downloads werden abgelehnt"
)
_check(
UpdateInfo.download_for(info, "linux").is_empty(),
"fehlende Plattformen liefern keine Datei"
)
func _test_date_format() -> void:
_check(
UpdateInfo.format_date("2026-11-11") == "11.11.2026",
"ISO-Datum wird deutsch formatiert"
)
_check(
UpdateInfo.format_date("11.11.2026") == "11.11.2026",
"unbekannte Formate bleiben unverändert"
)
func _test_skipped_state() -> void:
UpdateInfo.clear_skipped_version()
_check(
UpdateInfo.load_skipped_version().is_empty(),
"ohne Zustand ist keine Version übersprungen"
)
UpdateInfo.remember_skipped_version("0.2.0")
_check(
UpdateInfo.load_skipped_version() == "0.2.0",
"die übersprungene Version wird gespeichert"
)
UpdateInfo.clear_skipped_version()
_check(
UpdateInfo.load_skipped_version().is_empty(),
"der Zustand lässt sich zurücksetzen"
)
func _test_controller_wiring() -> void:
var scene := WhiteboardScene.instantiate()
var controller := scene as WhiteboardController
controller.restore_autosave = false
controller.autosave_enabled = false
controller.check_for_updates = false
root.add_child(scene)
await process_frame
_check(controller.update_dialog != null, "der Update-Dialog ist verdrahtet")
_check(controller.update_text != null, "der Update-Text ist verdrahtet")
var popup := controller.file_menu_button.get_popup()
_check(
_find_menu_item(popup, "Nach Updates suchen…") >= 0,
"das Datei-Menü bietet die manuelle Update-Prüfung"
)
var text := controller._update_dialog_text(
{
"version": "0.3.0",
"released": "2026-12-01",
"notes": "Testnotiz",
"platform": "macos",
},
{"size": 1048576},
"0.2.0"
)
_check(text.contains("Rinkplanner 0.3.0"), "der Dialog nennt die neue Version")
_check(text.contains("0.2.0"), "der Dialog nennt die installierte Version")
_check(text.contains("Testnotiz"), "der Dialog zeigt die Notizen")
scene.queue_free()
await process_frame
func _find_menu_item(popup: PopupMenu, text: String) -> int:
for index: int in range(popup.item_count):
if popup.get_item_text(index) == text:
return index
return -1
func _check(condition: bool, message: String) -> void:
_assertions += 1
if not condition:
_failures.append(message)
func _finish() -> void:
if _failures.is_empty():
print("Update tests: %d checks passed." % _assertions)
quit(0)
return
printerr("Update tests failed (%d/%d):" % [_failures.size(), _assertions])
for failure: String in _failures:
printerr(" - " + failure)
quit(1)

View file

@ -0,0 +1 @@
uid://ca5ghpa3v4utn