This commit is contained in:
2026-01-21 22:52:52 -08:00
parent d94e321148
commit 201663bb62
9 changed files with 377 additions and 124 deletions

View File

@@ -5,7 +5,7 @@ from pathlib import Path
import sys
import re
from SYS.logger import log
from SYS.logger import log, debug
from SYS import models
from SYS import pipeline as ctx
@@ -420,11 +420,9 @@ def _refresh_tag_view(
except Exception:
return
if not target_hash or not store_name:
if not target_hash:
return
refresh_args: List[str] = ["-query", f"hash:{target_hash}", "-store", store_name]
get_tag = None
try:
get_tag = get_cmdlet("get-tag")
@@ -435,14 +433,54 @@ def _refresh_tag_view(
try:
subject = ctx.get_last_result_subject()
if subject and _matches_target(subject, target_hash, target_path, store_name):
get_tag(subject, refresh_args, config)
if not subject or not _matches_target(subject, target_hash, target_path, store_name):
return
except Exception:
pass
try:
get_tag(res, refresh_args, config)
refresh_args: List[str] = ["-query", f"hash:{target_hash}"]
# Build a lean subject so get-tag fetches fresh tags instead of reusing cached payloads.
def _value_has_content(value: Any) -> bool:
if value is None:
return False
if isinstance(value, str):
return bool(value.strip())
if isinstance(value, (list, tuple, set)):
return len(value) > 0
return True
def _build_refresh_subject() -> Dict[str, Any]:
payload: Dict[str, Any] = {}
payload["hash"] = target_hash
if _value_has_content(store_name):
payload["store"] = store_name
path_value = target_path or get_field(subject, "path")
if not _value_has_content(path_value):
path_value = get_field(subject, "target")
if _value_has_content(path_value):
payload["path"] = path_value
for key in ("title", "name", "url", "relations", "service_name"):
val = get_field(subject, key)
if _value_has_content(val):
payload[key] = val
extra_value = get_field(subject, "extra")
if isinstance(extra_value, dict):
cleaned = {
k: v for k, v in extra_value.items()
if str(k).lower() not in {"tag", "tags"}
}
if cleaned:
payload["extra"] = cleaned
elif _value_has_content(extra_value):
payload["extra"] = extra_value
return payload
refresh_subject = _build_refresh_subject()
with ctx.suspend_live_progress():
get_tag(refresh_subject, refresh_args, config)
except Exception:
pass
@@ -643,7 +681,7 @@ class Add_Tag(Cmdlet):
total_added = 0
total_modified = 0
store_registry = Store(config)
store_registry = Store(config, suppress_debug=True)
extract_matched_items = 0
extract_no_match_items = 0
@@ -1004,7 +1042,7 @@ class Add_Tag(Cmdlet):
raw_path
)
if changed and not is_last_stage and not use_inline_tags:
if changed and not use_inline_tags:
_refresh_tag_view(res, resolved_hash, str(store_name), raw_path, config)
if is_last_stage: