From 3115ed28b2a920b0a158962715a25bbf50763194 Mon Sep 17 00:00:00 2001 From: jxxghp Date: Mon, 26 Jan 2026 21:47:26 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8E=86=E5=8F=B2=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=BA=90=E6=96=87=E4=BB=B6=E5=90=8E=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E5=9C=A8=E8=AE=A2=E9=98=85=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=AD=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/endpoints/history.py | 5 ++++- app/chain/subscribe.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/api/endpoints/history.py b/app/api/endpoints/history.py index 306e4234..4b0708e3 100644 --- a/app/api/endpoints/history.py +++ b/app/api/endpoints/history.py @@ -4,6 +4,7 @@ import jieba from fastapi import APIRouter, Depends from sqlalchemy.ext.asyncio import AsyncSession from sqlalchemy.orm import Session +from pathlib import Path from app import schemas from app.chain.storage import StorageChain @@ -11,7 +12,7 @@ from app.core.event import eventmanager from app.core.security import verify_token from app.db import get_async_db, get_db from app.db.models import User -from app.db.models.downloadhistory import DownloadHistory +from app.db.models.downloadhistory import DownloadHistory, DownloadFiles from app.db.models.transferhistory import TransferHistory from app.db.user_oper import get_current_active_superuser_async, get_current_active_superuser from app.schemas.types import EventType @@ -98,6 +99,8 @@ def delete_transfer_history(history_in: schemas.TransferHistory, state = StorageChain().delete_media_file(src_fileitem) if not state: return schemas.Response(success=False, message=f"{src_fileitem.path} 删除失败") + # 删除下载记录中关联的文件 + DownloadFiles.delete_by_fullpath(db, Path(src_fileitem.path).as_posix()) # 发送事件 eventmanager.send_event( EventType.DownloadFileDeleted, diff --git a/app/chain/subscribe.py b/app/chain/subscribe.py index f7798263..d0f67c46 100644 --- a/app/chain/subscribe.py +++ b/app/chain/subscribe.py @@ -1668,7 +1668,7 @@ class SubscribeChain(ChainBase): if download_his: for his in download_his: # 查询下载文件 - files = downloadhis.get_files_by_hash(his.download_hash) + files = downloadhis.get_files_by_hash(his.download_hash, state=1) if files: for file in files: # 识别文件名