fix(后端): 修复模型管理API异常泄漏和废弃API
- 修复模型管理API中异常信息泄漏到客户端的问题 - 迁移datetime.utcnow为datetime.now(timezone.utc)
This commit is contained in:
1 parent
5e1113f132
commit
dc36727c3e
1 file changed
+5
-5
@@ -369,7 +369,7 @@ def upload_model():
|
||||
|
||||
# Secure the filename and create storage path
|
||||
filename = secure_filename(file.filename)
|
||||
timestamp = datetime.utcnow().strftime("%Y%m%d_%H%M%S")
|
||||
timestamp = datetime.now(timezone.utc).strftime("%Y%m%d_%H%M%S")
|
||||
safe_task_name = secure_filename(task_name)
|
||||
storage_filename = f"{safe_task_name}_{timestamp}_{filename}"
|
||||
|
||||
@@ -785,7 +785,7 @@ def update_model(model_id):
|
||||
return success(data={"id": model.id}, msg="未检测到变更")
|
||||
|
||||
# 更新 updated_at 时间戳
|
||||
model.updated_at = datetime.utcnow()
|
||||
model.updated_at = datetime.now(timezone.utc)
|
||||
|
||||
# 记录审计日志
|
||||
for entry in audit_entries:
|
||||
@@ -1073,7 +1073,7 @@ def scan_model_files():
|
||||
continue
|
||||
except Exception as e:
|
||||
logger.error(f"扫描目录失败: {str(e)}")
|
||||
return error(msg=f"扫描目录失败: {str(e)}", code=500)
|
||||
return error(msg="扫描目录失败", code=500)
|
||||
|
||||
return success(
|
||||
data={
|
||||
@@ -1228,11 +1228,11 @@ def test_model_output():
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"推理执行失败: {str(e)}")
|
||||
return error(msg=f"推理执行失败: {str(e)}", code=500)
|
||||
return error(msg="模型测试失败,请稍后重试", code=500)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"模型加载失败: {str(e)}")
|
||||
return error(msg=f"模型加载失败: {str(e)}", code=500)
|
||||
return error(msg="模型加载失败,请稍后重试", code=500)
|
||||
|
||||
|
||||
@api.route("/admin/models/<int:model_id>/labels", methods=["POST"])
|
||||
|
||||
Reference in new issue
Block a user