dfd
This commit is contained in:
@@ -79,6 +79,31 @@ def add(result: Any, args: Sequence[str], config: Dict[str, Any]) -> int:
|
||||
except Exception as exc:
|
||||
log(f"Hydrus add-note failed: {exc}")
|
||||
return 1
|
||||
|
||||
# Refresh notes view if we're operating on the currently selected subject
|
||||
try:
|
||||
from cmdlets import get_note as get_note_cmd # type: ignore
|
||||
except Exception:
|
||||
get_note_cmd = None
|
||||
if get_note_cmd:
|
||||
try:
|
||||
subject = ctx.get_last_result_subject()
|
||||
if subject is not None:
|
||||
def norm(val: Any) -> str:
|
||||
return str(val).lower()
|
||||
target_hash = norm(hash_hex) if hash_hex else None
|
||||
subj_hashes = []
|
||||
if isinstance(subject, dict):
|
||||
subj_hashes = [norm(v) for v in [subject.get("hydrus_hash"), subject.get("hash"), subject.get("hash_hex"), subject.get("file_hash")] if v]
|
||||
else:
|
||||
subj_hashes = [norm(getattr(subject, f, None)) for f in ("hydrus_hash", "hash", "hash_hex", "file_hash") if getattr(subject, f, None)]
|
||||
if target_hash and target_hash in subj_hashes:
|
||||
get_note_cmd.get_notes(subject, ["-hash", hash_hex], config)
|
||||
return 0
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
ctx.emit(f"Added note '{name}' ({len(text)} chars)")
|
||||
|
||||
return 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user