diff --git a/services/wolf.sh b/services/wolf.sh index 43c93bd..30c926b 100644 --- a/services/wolf.sh +++ b/services/wolf.sh @@ -1820,6 +1820,33 @@ def update_field(lines, wolf_name, field, new_value): return True return False +def update_scalar_field(lines, wolf_name, field, new_value): + # Same block-bounding as update_field, but for a single-line scalar + # string field (image, icon_png_path) that Wolf never reformats across + # multiple lines. update_field's array logic (which scans forward + # hunting for a closing ']') isn't safe to reuse here — a scalar line + # has no ']' of its own and that scan would run off into an unrelated + # array field further down the same block (e.g. 'ports = []'), + # corrupting it. Confirmed needed live: a stale 'image' field (e.g. the + # games-on-whales/desktop -> xfce rename) was NOT refreshed by + # update_field, since only 'mounts'/'env' were ever passed to it — an + # already-installed app's broken image reference survived every + # reinstall/'./manage.sh apps' re-run until this was added. + for i, line in enumerate(lines): + if f"name = '{wolf_name}'" in line: + block_start = i + while block_start > 0 and lines[block_start].strip() != '[[profiles.apps]]': + block_start -= 1 + block_end = i + 1 + while block_end < len(lines) and lines[block_end].strip() not in ('[[profiles.apps]]', '[[profiles]]'): + block_end += 1 + for j in range(block_start, block_end): + if lines[j].lstrip().startswith(field + " = '"): + indent = lines[j][:len(lines[j]) - len(lines[j].lstrip())] + lines[j] = f"{indent}{field} = '{new_value}'\n" + return True + return False + with open(cfg, 'r') as f: lines = f.readlines() @@ -1846,6 +1873,8 @@ for key in list(CATALOG.keys()): if already: ok = update_field(lines, wolf_name, 'mounts', new_mounts) ok = update_field(lines, wolf_name, 'env', new_env) or ok + ok = update_scalar_field(lines, wolf_name, 'image', app['image']) or ok + ok = update_scalar_field(lines, wolf_name, 'icon_png_path', app['icon']) or ok if ok: updated.append(app['title']) else: @@ -3244,6 +3273,33 @@ def update_field(lines, wolf_name, field, new_value): return True return False +def update_scalar_field(lines, wolf_name, field, new_value): + # Same block-bounding as update_field, but for a single-line scalar + # string field (image, icon_png_path) that Wolf never reformats across + # multiple lines. update_field's array logic (which scans forward + # hunting for a closing ']') isn't safe to reuse here — a scalar line + # has no ']' of its own and that scan would run off into an unrelated + # array field further down the same block (e.g. 'ports = []'), + # corrupting it. Confirmed needed live: a stale 'image' field (e.g. the + # games-on-whales/desktop -> xfce rename) was NOT refreshed by + # update_field, since only 'mounts'/'env' were ever passed to it — an + # already-installed app's broken image reference survived every + # './manage.sh apps' re-run until this was added. + for i, line in enumerate(lines): + if f"name = '{wolf_name}'" in line: + block_start = i + while block_start > 0 and lines[block_start].strip() != '[[profiles.apps]]': + block_start -= 1 + block_end = i + 1 + while block_end < len(lines) and lines[block_end].strip() not in ('[[profiles.apps]]', '[[profiles]]'): + block_end += 1 + for j in range(block_start, block_end): + if lines[j].lstrip().startswith(field + " = '"): + indent = lines[j][:len(lines[j]) - len(lines[j].lstrip())] + lines[j] = f"{indent}{field} = '{new_value}'\n" + return True + return False + with open(cfg, 'r') as f: lines = f.readlines() @@ -3273,6 +3329,8 @@ for key in list(CATALOG.keys()): # preserve display order if already: ok = update_field(lines, wolf_name, 'mounts', new_mounts) ok = update_field(lines, wolf_name, 'env', new_env) or ok + ok = update_scalar_field(lines, wolf_name, 'image', app['image']) or ok + ok = update_scalar_field(lines, wolf_name, 'icon_png_path', app['icon']) or ok if ok: updated.append(app['title']) else: