✨ feat(core): 引入垃圾回收管理功能
* 新增垃圾回收管理逻辑,支持批量管理与清理功能 * 在数据模型中增加过期时间与保留天数验证逻辑 * 在 FileService 中集成垃圾回收管理模块 * 调整任务调度逻辑以适配新的垃圾回收规则 * 为垃圾回收功能补充相应的单元测试覆盖
This commit is contained in:
1 parent
356f23bae1
commit
b10113e5ab
6 files changed
+388
-46
No files matched your search
+4
-1
@@ -18,6 +18,7 @@ from apps.admin.services import FileService
|
||||
from apps.base.utils import ip_limit, get_chunk_file_path_name
|
||||
from core.config import refresh_settings
|
||||
from core.logger import logger
|
||||
from apps.admin.trash_management import automatic_trash_reason
|
||||
from core.settings import settings, data_root
|
||||
from core.storage import FileStorageInterface, storages
|
||||
from core.utils import get_now
|
||||
@@ -43,7 +44,9 @@ async def delete_expire_files():
|
||||
).filter(Q(expired_at__lt=await get_now()) | Q(expired_count=0)).all()
|
||||
for exp in expire_data:
|
||||
try:
|
||||
await file_service.move_to_trash(exp, reason="expired")
|
||||
reason = automatic_trash_reason(exp, await get_now())
|
||||
if reason is not None:
|
||||
await file_service.move_to_trash(exp, reason=reason)
|
||||
except Exception as e:
|
||||
logger.error(f"移入过期文件回收站失败 code={exp.code}: {e}")
|
||||
expired_trash = await FileCodes.filter(
|
||||
|
||||
Reference in new issue
Block a user