Commit 815be628 authored by 郭阔's avatar 郭阔

fix(harvest): 推送脚本层兜底——会话拒绝推送时自动补推

实测 reuters-technology 15:30 与 markets 12:00 两场:归档/摘要/finalize 全部
完成,但会话以'避免未授权的外部发布'为由跳过自动推送(模型主观拒判)。
现改为:运行结束时有交付而 day 目录 syncstate 未在本次窗口内更新 →
脚本直接补推(push.js 幂等);摘要未齐等推送前置不满足时留待下次自动重检。
本次 8 篇已手工补推并经服务器 unchanged 确认在库。
parent cdf420fc
...@@ -429,6 +429,31 @@ if [ "$STATUS_TAG" = "FAILED" ] && command -v jq >/dev/null 2>&1 && [ -s "$JSON_ ...@@ -429,6 +429,31 @@ if [ "$STATUS_TAG" = "FAILED" ] && command -v jq >/dev/null 2>&1 && [ -s "$JSON_
fi fi
fi fi
# --- 推送兜底:采集会话偶尔会以"避免未授权外部发布"为由跳过推送(实测发生过,
# 归档/摘要/finalize 都完成唯独不推)。只要本次有交付而 day 目录 syncstate
# 没在本次运行窗口内更新过,脚本层直接补推(push 幂等,失败下次再检) ---
if [ "$STATUS_TAG" != "FAILED" ] && command -v jq >/dev/null 2>&1; then
_p_succ="$(jq -r '.result.succeeded_count // 0' "$JSON_OUT" 2>/dev/null)"
_p_skill="$(nh_skill_dir 2>/dev/null || true)"
if [ "${_p_succ:-0}" -gt 0 ] && [ -n "$_p_skill" ] && [ -f "$_p_skill/config.json" ]; then
_p_folder="$(jq -r '.sources[] | select(.id == "'"$SOURCE"'") | .vaultFolder // empty' "$_p_skill/config.json" 2>/dev/null)"
if [ -n "$_p_folder" ]; then
_p_day="${OBSIDIAN_VAULT_PATH:-$HOME/NewsHub}/${_p_folder}/${DATE_TAG}"
_p_sync="$_p_day/.syncstate.json"
_p_fresh=0
if [ -f "$_p_sync" ]; then
_p_ep="$(python3 -c "import os,sys;print(int(os.path.getmtime(sys.argv[1])))" "$_p_sync" 2>/dev/null || echo 0)"
[ "$_p_ep" -ge "$START_EPOCH" ] && _p_fresh=1
fi
if [ "$_p_fresh" = "0" ] && [ -d "$_p_day" ]; then
echo "[push-backfill] 本次有交付但推送未确认(syncstate 未更新),脚本层补推 $_p_day"
(cd "$_p_skill" && node scripts/push.js "$_p_day" 2>&1 | tail -4 | sed 's/^/ [push] /') \
|| echo "[push-backfill] 补推未成功(如摘要未齐),下次运行会自动重检"
fi
fi
fi
fi
# --- 格式化耗时 --- # --- 格式化耗时 ---
MINS=$((WALL_DURATION / 60)) MINS=$((WALL_DURATION / 60))
SECS=$((WALL_DURATION % 60)) SECS=$((WALL_DURATION % 60))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment