Skip to content

Commit 9fa3f51

Browse files
committed
fix: 修复 /openbmclapi/download 接口给你 warden 了
1 parent c1b9bfd commit 9fa3f51

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

core/cluster.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,17 @@ async def get_file(self, hash: str):
165165
}
166166
) as session:
167167
async with session.get(
168-
f"/openbmclapi/download/{hash}"
168+
f"/openbmclapi/download/{hash}",
169+
params={
170+
"noopen": str(1)
171+
}
169172
) as resp:
173+
# check hash, if hash is not mismatch.
174+
body = await resp.content.read()
175+
utils.raise_service_error(body)
176+
got_hash = utils.get_hash_hexdigest(hash, body)
177+
if got_hash != hash:
178+
logger.terror("cluster.error.download_hash", got_hash=got_hash, hash=hash, content=body.decode("utf-8", "ignore")[:64])
170179
file = MemoryStorageFile(
171180
hash,
172181
resp.content_length or -1,

i18n/zh_cn.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@
3636
"cluster.error.socketio.warden": "[Warden] 节点 [${cluster}] 收到错误消息,原因 [${message}]",
3737
"utils.error.service_error": "服务出错,状态码 [${code}(${httpCode})] 类型 [${name}] 信息 [${message}]",
3838
"web.warning.server_down": "当前 [${port}] 端口已重新开启",
39-
"web.traceback.check_server": "当前 [${port}] 端口没有通过检查,原因是:"
39+
"web.traceback.check_server": "当前 [${port}] 端口没有通过检查,原因是:",
40+
"cluster.error.download_hash": "通过主控下载文件出错,本来的哈希是 [${hash}],获取到的哈希是 [${got_hash}],内容为 [${content}]"
4041
}

0 commit comments

Comments
 (0)