Skip to content

Commit cdc96f5

Browse files
committed
relaunch after update part two
1 parent 8b826dc commit cdc96f5

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

src/redfetch/main.py

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -306,19 +306,6 @@ def resources_reset_command():
306306

307307
#region Launching
308308

309-
def _should_relaunch_after_pyapp_update() -> bool:
310-
"""Relaunch after a PYAPP self-update only for double-click/Explorer launches."""
311-
if sys.platform != "win32" or not os.getenv("PYAPP"):
312-
return False
313-
try:
314-
import psutil # type: ignore
315-
316-
parent = psutil.Process().parent()
317-
return bool(parent and parent.name().lower() == "explorer.exe")
318-
except Exception:
319-
return False
320-
321-
322309
@app.command(
323310
"ui",
324311
help="Launch the [italic]Terminal User Interface[/italic].",
@@ -329,7 +316,10 @@ def run_tui():
329316
# Initialize config early; terminal_ui accesses config at import time
330317
config.initialize_config()
331318
if os.environ.get('CI') != 'true':
332-
_ = meta.check_for_update(relaunch=_should_relaunch_after_pyapp_update())
319+
# Always relaunch after a PyApp self-update on Windows so the user
320+
# lands back in the TUI without having to re-open the app.
321+
relaunch = sys.platform == "win32" and bool(os.getenv("PYAPP"))
322+
_ = meta.check_for_update(relaunch=relaunch)
333323
# Ensure the user is authorized before launching UI
334324
auth.initialize_keyring()
335325
auth.authorize()

0 commit comments

Comments
 (0)