From fbdd3fa31b68449c28e1f9c7fcc9d6728042307d Mon Sep 17 00:00:00 2001 From: yuming Date: Thu, 23 Apr 2026 13:12:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BB=BB=E5=8A=A1=E9=98=9F=E5=88=97?= =?UTF-8?q?=E6=94=B9=E4=BB=8E=20app.chat=5Fdownload=5Fconfig=20=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=9E=84=E9=80=A0=EF=BC=8C=E8=A7=A3=E5=86=B3=20os.exe?= =?UTF-8?q?cv=E9=87=8D=E5=90=AF=E5=90=8E=20=5Ftask=5Fqueue=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E5=8F=98=E9=87=8F=E4=B8=A2=E5=A4=B1=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E9=98=9F=E5=88=97=E5=8F=AA=E6=98=BE=E7=A4=BA=201=20=E4=B8=AA?= =?UTF-8?q?=E9=A2=91=E9=81=93=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/web.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/module/web.py b/module/web.py index a85f37a..9970641 100644 --- a/module/web.py +++ b/module/web.py @@ -200,11 +200,37 @@ def get_download_speed(): ) +def _compute_current_task_queue() -> list: + """动态构造当前任务队列。 + 由于 restart 走 os.execv,download_stat 里的 _task_queue 全局变量会丢; + 所以真实来源以 _app.chat_download_config(config.yaml 重载后的结果)为准, + chat_title 从 channel_history 查。 + """ + global _app + if not _app or not _app.chat_download_config: + return [] + history_map = {} + for h in _load_channel_history(): + cid = str(h.get("chat_id", "") or "") + if cid: + history_map[cid] = h.get("chat_title", "") or cid + queue = [] + for chat_id in _app.chat_download_config.keys(): + cid_str = str(chat_id) + queue.append({ + "chat_id": cid_str, + "chat_title": history_map.get(cid_str, cid_str), + }) + return queue + + @_flask_app.route("/api/task_progress") @login_required def api_task_progress(): """Get current task progress including skipped files""" progress = get_task_progress() + # 覆盖 task_queue:download_stat 里的全局变量在 os.execv 重启后会丢,用 app 动态算才稳 + progress["task_queue"] = _compute_current_task_queue() return jsonify(progress)