f
This commit is contained in:
@@ -146,6 +146,26 @@ class PipelineProgress:
|
|||||||
except Exception:
|
except Exception:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def begin_pipe(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
total_items: int,
|
||||||
|
items_preview: Optional[Sequence[Any]] = None
|
||||||
|
) -> None:
|
||||||
|
ui, pipe_idx = self.ui_and_pipe_index()
|
||||||
|
if ui is None:
|
||||||
|
return
|
||||||
|
try:
|
||||||
|
fn = getattr(ui, "begin_pipe", None)
|
||||||
|
if callable(fn):
|
||||||
|
fn(
|
||||||
|
int(pipe_idx),
|
||||||
|
total_items=max(1, int(total_items)),
|
||||||
|
items_preview=list(items_preview or []),
|
||||||
|
)
|
||||||
|
except Exception:
|
||||||
|
return
|
||||||
|
|
||||||
def on_emit(self, emitted: Any) -> None:
|
def on_emit(self, emitted: Any) -> None:
|
||||||
"""Advance local pipe progress after pipeline_context.emit().
|
"""Advance local pipe progress after pipeline_context.emit().
|
||||||
|
|
||||||
|
|||||||
@@ -223,30 +223,11 @@ class Add_File(Cmdlet):
|
|||||||
try:
|
try:
|
||||||
candidate_dir = Path(str(path_arg))
|
candidate_dir = Path(str(path_arg))
|
||||||
if candidate_dir.exists() and candidate_dir.is_dir():
|
if candidate_dir.exists() and candidate_dir.is_dir():
|
||||||
piped_items = result if isinstance(result, list) else [result]
|
debug(
|
||||||
has_local_source = False
|
f"[add-file] Treating -path directory as destination: {candidate_dir}"
|
||||||
for it in piped_items:
|
)
|
||||||
try:
|
location = str(candidate_dir)
|
||||||
po = coerce_to_pipe_object(it, None)
|
path_arg = None
|
||||||
src = str(getattr(po, "path", "") or "").strip()
|
|
||||||
if not src:
|
|
||||||
continue
|
|
||||||
if src.lower().startswith(("http://",
|
|
||||||
"https://",
|
|
||||||
"magnet:",
|
|
||||||
"torrent:")):
|
|
||||||
continue
|
|
||||||
if Path(src).is_file():
|
|
||||||
has_local_source = True
|
|
||||||
break
|
|
||||||
except Exception:
|
|
||||||
continue
|
|
||||||
if has_local_source:
|
|
||||||
debug(
|
|
||||||
f"[add-file] Treating -path directory as destination: {candidate_dir}"
|
|
||||||
)
|
|
||||||
location = str(candidate_dir)
|
|
||||||
path_arg = None
|
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@@ -693,8 +674,8 @@ class Add_File(Cmdlet):
|
|||||||
# Legacy search-file refresh is no longer used for final display.
|
# Legacy search-file refresh is no longer used for final display.
|
||||||
if want_final_search_file and collected_payloads:
|
if want_final_search_file and collected_payloads:
|
||||||
try:
|
try:
|
||||||
from SYS.result_table import Table
|
|
||||||
from SYS.rich_display import render_item_details_panel
|
from SYS.rich_display import render_item_details_panel
|
||||||
|
from SYS.result_table import Table
|
||||||
|
|
||||||
# Stop the live pipeline progress UI before rendering the details panels.
|
# Stop the live pipeline progress UI before rendering the details panels.
|
||||||
# This prevents the progress display from lingering on screen.
|
# This prevents the progress display from lingering on screen.
|
||||||
@@ -736,6 +717,11 @@ class Add_File(Cmdlet):
|
|||||||
collected_payloads,
|
collected_payloads,
|
||||||
subject=subject
|
subject=subject
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
|
ctx.set_last_result_items_only(list(collected_payloads))
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|||||||
@@ -1887,18 +1887,26 @@ class Download_File(Cmdlet):
|
|||||||
|
|
||||||
debug(f"Output directory: {final_output_dir}")
|
debug(f"Output directory: {final_output_dir}")
|
||||||
|
|
||||||
|
progress = PipelineProgress(pipeline_context)
|
||||||
try:
|
try:
|
||||||
# If we are already in a pipeline stage, the parent UI is already handling progress.
|
# If we are already in a pipeline stage, the parent UI is already handling progress.
|
||||||
# Calling ensure_local_ui can cause re-initialization hangs on some platforms.
|
# Calling ensure_local_ui can cause re-initialization hangs on some platforms.
|
||||||
if pipeline_context.get_stage_context() is None:
|
if pipeline_context.get_stage_context() is None:
|
||||||
debug("[download-file] Initializing local UI...")
|
debug("[download-file] Initializing local UI...")
|
||||||
PipelineProgress(pipeline_context).ensure_local_ui(
|
progress.ensure_local_ui(
|
||||||
label="download-file",
|
label="download-file",
|
||||||
total_items=len(supported_url),
|
total_items=len(supported_url),
|
||||||
items_preview=supported_url,
|
items_preview=supported_url,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
debug("[download-file] Skipping local UI: running inside pipeline stage")
|
debug("[download-file] Skipping local UI: running inside pipeline stage")
|
||||||
|
try:
|
||||||
|
progress.begin_pipe(
|
||||||
|
total_items=len(supported_url),
|
||||||
|
items_preview=supported_url,
|
||||||
|
)
|
||||||
|
except Exception as err:
|
||||||
|
debug(f"[download-file] PipelineProgress begin_pipe error: {err}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
debug(f"[download-file] PipelineProgress update error: {e}")
|
debug(f"[download-file] PipelineProgress update error: {e}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user