df
Some checks failed
smoke-mm / Install & smoke test mm --help (push) Has been cancelled

This commit is contained in:
2025-12-27 14:50:59 -08:00
parent 22af776ee2
commit fcdd507d00
12 changed files with 1004 additions and 66 deletions

47
CLI.py
View File

@@ -1012,6 +1012,14 @@ class CmdletExecutor:
ensure_registry_loaded()
# REPL guard: stage-local selection tables should not leak across independent
# commands. @ selection can always re-seed from the last result table.
try:
if hasattr(ctx, "set_current_stage_table"):
ctx.set_current_stage_table(None)
except Exception:
pass
cmd_fn = REGISTRY.get(cmd_name)
if not cmd_fn:
# Lazy-import module and register its CMDLET.
@@ -1451,6 +1459,13 @@ class CmdletExecutor:
ctx.set_live_progress(None)
except Exception:
pass
# Do not keep stage tables around after a single command; it can cause
# later @ selections to bind to stale tables (e.g. old add-file scans).
try:
if hasattr(ctx, "set_current_stage_table"):
ctx.set_current_stage_table(None)
except Exception:
pass
try:
if hasattr(ctx, "clear_current_cmdlet_name"):
ctx.clear_current_cmdlet_name()
@@ -2027,6 +2042,9 @@ class PipelineExecutor:
elif table_type == "bandcamp":
print("Auto-running Bandcamp selection via download-media")
stages.append(["download-media"])
elif table_type == "internetarchive":
print("Auto-loading Internet Archive item via download-data")
stages.append(["download-data"])
elif table_type in {"soulseek", "openlibrary", "libgen"}:
print("Auto-piping selection to download-file")
stages.append(["download-file"])
@@ -2056,6 +2074,16 @@ class PipelineExecutor:
):
print("Auto-inserting download-media after Bandcamp selection")
stages.insert(0, ["download-media"])
if table_type == "internetarchive" and first_cmd not in (
"download-data",
"download_data",
"download-file",
"download-media",
"download_media",
".pipe",
):
debug("Auto-inserting download-data after Internet Archive selection")
stages.insert(0, ["download-data"])
if table_type == "libgen" and first_cmd not in (
"download-file",
"download-media",
@@ -2166,6 +2194,14 @@ class PipelineExecutor:
try:
self._try_clear_pipeline_stop(ctx)
# REPL guard: stage-local tables should not persist across independent
# commands. Selection stages can always seed from last/display tables.
try:
if hasattr(ctx, "set_current_stage_table"):
ctx.set_current_stage_table(None)
except Exception:
pass
# Preflight (URL-duplicate prompts, etc.) should be cached within a single
# pipeline run, not across independent pipelines.
try:
@@ -2615,11 +2651,13 @@ class PipelineExecutor:
if (
(not stage_is_last)
and (not emits)
and cmd_name in {"download-media", "download_media"}
and cmd_name in {"download-media", "download_media", "download-data", "download_data"}
and stage_table is not None
and (
stage_table_type in {"ytdlp.formatlist", "download-media", "download_media", "bandcamp", "youtube"}
or stage_table_source in {"download-media", "download_media"}
or stage_table_type in {"internetarchive.formats"}
or stage_table_source in {"download-file"}
)
):
try:
@@ -2812,6 +2850,13 @@ class PipelineExecutor:
_pipeline_ctx.set_live_progress(None)
except Exception:
pass
# End-of-command cleanup: avoid leaking current stage tables into
# the next REPL command (causes stale @ selection sources).
try:
if hasattr(ctx, "set_current_stage_table"):
ctx.set_current_stage_table(None)
except Exception:
pass
if pipeline_session:
pipeline_session.close(status=pipeline_status, error_msg=pipeline_error)
except Exception as exc: