mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-09-26 03:14:01 +02:00
fix(free_games_claimer): address review findings on the data migration
Three defects found by the Codex and CodeRabbit PR reviewers, all reproduced before being accepted: - A CONFIG_LOCATION under /config/data (for example /config/data/custom.env) made "mkdir -p $HOME" create the migration's own guard directory before the guard was tested, so the migration silently skipped itself and the add-on started with no claim history and no authenticated sessions. The migration now runs before the CONFIG_LOCATION directory is created. - The copy list held prime-gaming.json but not epic-games.json or gog.json, although migrate_vogler_data.py's locate_source() supports all three at the data root. A user whose only legacy history was Epic or GOG would have had the migrator write a completion marker with zero imported records. - fgc.db-journal was not copied. Upstream sets no PRAGMA journal_mode, so SQLite runs in its default rollback-journal mode and a hot journal left by an unclean stop is needed to recover the database. Also: CONFIG_LOCATION=/config/data/config.env made CONFIG_FILE and RUNTIME_CONFIG the same path, and GNU install refuses a self-copy with status 1, which aborted the "set -e" init script before the application started. Verified: "install -m 0600 f f" exits 1 with "are the same file". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -7,9 +7,10 @@
|
||||
the `screenshots/` captures, the `browser/` profiles, `TurboVNC.log` and
|
||||
upstream's debug dumps (#3081).
|
||||
- An existing `/data` payload is copied over once on the first start of this
|
||||
version: `fgc.db` and its pre-migration backup, `browser/`, `screenshots/`,
|
||||
`prime-gaming.json`, the legacy `data/` directory and the migration marker.
|
||||
Logs and last-run debug dumps are not copied, because the application
|
||||
version: `fgc.db` with its rollback journal and its pre-migration backup,
|
||||
`browser/`, `screenshots/`, the `epic-games.json`, `prime-gaming.json` and
|
||||
`gog.json` claim histories, the legacy `data/` directory and the migration
|
||||
marker. Logs and last-run debug dumps are not copied, because the application
|
||||
regenerates them. The copy is staged and renamed into place, so an interrupted
|
||||
migration is retried rather than leaving a half-copied database or browser
|
||||
profile. Nothing is deleted from `/data`: the migration needs temporary free
|
||||
|
||||
@@ -2,13 +2,6 @@
|
||||
# shellcheck shell=bash
|
||||
set -e
|
||||
|
||||
# Define home
|
||||
# Creating config location
|
||||
echo "Creating config location ..."
|
||||
HOME="$(bashio::config "CONFIG_LOCATION")"
|
||||
HOME="$(dirname "$HOME")"
|
||||
mkdir -p "$HOME"
|
||||
|
||||
# Up to version 2.1.1 the application stored its data in the add-on's private
|
||||
# /data volume, which is only reachable with "docker exec". It now lives in
|
||||
# /config/data, which Home Assistant exposes as
|
||||
@@ -17,10 +10,15 @@ mkdir -p "$HOME"
|
||||
# is retried on the next start instead of leaving a half-copied database or
|
||||
# browser profile behind. Nothing is removed from /data, so downgrading still
|
||||
# finds its data.
|
||||
#
|
||||
# This runs before the CONFIG_LOCATION directory is created below: a
|
||||
# CONFIG_LOCATION under /config/data would otherwise create the destination
|
||||
# and make the migration skip itself.
|
||||
if [ ! -d /config/data ]; then
|
||||
legacy=()
|
||||
for entry in fgc.db fgc.db.pre-vogler-migration .vogler-remaster-migrated-v1.json \
|
||||
browser screenshots data prime-gaming.json; do
|
||||
for entry in fgc.db fgc.db-journal fgc.db.pre-vogler-migration \
|
||||
.vogler-remaster-migrated-v1.json browser screenshots data \
|
||||
epic-games.json prime-gaming.json gog.json; do
|
||||
if [ -e "/data/$entry" ]; then
|
||||
legacy+=("/data/$entry")
|
||||
fi
|
||||
@@ -35,3 +33,10 @@ if [ ! -d /config/data ]; then
|
||||
fi
|
||||
|
||||
mkdir -p /config/data
|
||||
|
||||
# Define home
|
||||
# Creating config location
|
||||
echo "Creating config location ..."
|
||||
HOME="$(bashio::config "CONFIG_LOCATION")"
|
||||
HOME="$(dirname "$HOME")"
|
||||
mkdir -p "$HOME"
|
||||
|
||||
@@ -27,7 +27,10 @@ fi
|
||||
|
||||
# The remaster reads /fgc/data/config.env. /fgc/data is linked to /config/data
|
||||
# by the Dockerfile, so the runtime copy is visible under /addon_configs.
|
||||
install -m 0600 "${CONFIG_FILE}" "${RUNTIME_CONFIG}"
|
||||
# CONFIG_LOCATION may itself be /config/data/config.env, in which case the two
|
||||
# paths are the same file and install would fail.
|
||||
[ "${CONFIG_FILE}" -ef "${RUNTIME_CONFIG}" ] || install "${CONFIG_FILE}" "${RUNTIME_CONFIG}"
|
||||
chmod 0600 "${RUNTIME_CONFIG}"
|
||||
sed -i 's/\r$//' "${RUNTIME_CONFIG}"
|
||||
|
||||
# Export values needed by the VNC entrypoint as well as by the Python app.
|
||||
|
||||
Reference in New Issue
Block a user