Skip to content

Commit f1c80a4

Browse files
committed
fix: 修复主控补全文件没有加 Bearer 的问题,并且增加 cluster 当被封禁的时候自动切换下一个
1 parent 44dba7e commit f1c80a4

File tree

2 files changed

+55
-23
lines changed

2 files changed

+55
-23
lines changed

assets/js/index.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ class SideMenu extends Element {
444444
constructor() {
445445
super("aside")
446446
this._menus = {}
447+
this._menuButtons = {}
447448
//
448449
}
449450
// split "." for submenu
@@ -467,7 +468,8 @@ class SideMenu extends Element {
467468
}
468469
}
469470
renderButtons() {
470-
471+
const buttons = [];
472+
foreach (k in this._menus)
471473
}
472474
clear() {
473475

@@ -554,6 +556,34 @@ $style.addAll({
554556
"opacity": "1",
555557
"transition": "min-width 250ms linear, width 250ms linear, padding 250ms linear, box-shadow 250ms linear, opacity 250ms linear",
556558
"background": "var(--background)"
559+
},
560+
"aside .menu": {
561+
"cursor": "pointer",
562+
"user-select": "none",
563+
"vertical-align": "middle",
564+
"appearance": "none",
565+
"color": "inherit",
566+
"display": "flex",
567+
"-webkit-box-flex": "1",
568+
"-webkit-box-pack": "start",
569+
"justify-content": "space-between",
570+
"-webkit-box-align": "center",
571+
"align-items": "center",
572+
"position": "relative",
573+
"min-width": "0px",
574+
"box-sizing": "border-box",
575+
"text-align": "left",
576+
"height": "46px",
577+
"outline": "0px",
578+
"border-width": "0px",
579+
"border-style": "initial",
580+
"border-color": "initial",
581+
"border-image": "initial",
582+
"margin": "0px 0px 4px",
583+
"text-decoration": "none",
584+
"padding": "8px 16px",
585+
"transition": "background-color 150ms cubic-bezier(0.4, 0, 0.2, 1)",
586+
"border-radius": "4px",
557587
}
558588
})
559589
function load() {

core/cluster.py

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -159,29 +159,31 @@ async def get_file(self, hash: str):
159159
if file is None:
160160
async with aiohttp.ClientSession(
161161
config.const.base_url,
162-
headers={
163-
"User-Agent": USER_AGENT,
164-
"Authorization": await self.clusters.clusters[0].get_token()
165-
}
166162
) as session:
167-
async with session.get(
168-
f"/openbmclapi/download/{hash}",
169-
params={
170-
"noopen": str(1)
171-
}
172-
) 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])
179-
file = MemoryStorageFile(
180-
hash,
181-
resp.content_length or -1,
182-
time.time(),
183-
await resp.content.read()
184-
)
163+
for cluster in self.clusters.clusters:
164+
async with session.get(
165+
f"/openbmclapi/download/{hash}",
166+
params={
167+
"noopen": str(1)
168+
},
169+
headers={
170+
"User-Agent": USER_AGENT,
171+
"Authorization": f"Bearer {await cluster.get_token()}"
172+
}
173+
) as resp:
174+
# check hash, if hash is not mismatch.
175+
body = await resp.content.read()
176+
utils.raise_service_error(body)
177+
got_hash = utils.get_hash_hexdigest(hash, body)
178+
file = MemoryStorageFile(
179+
hash,
180+
resp.content_length or -1,
181+
time.time(),
182+
await resp.content.read()
183+
)
184+
if got_hash == hash:
185+
break
186+
logger.terror("cluster.error.download_hash", got_hash=got_hash, hash=hash, content=body.decode("utf-8", "ignore")[:64])
185187
return file
186188

187189
def get_width_storage(self, c_storage: Optional[storages.iStorage] = None) -> storages.iStorage:

0 commit comments

Comments
 (0)