Skip to content

Commit 47f1cf8

Browse files
committed
fix: 修复一下存储没有权重的问题(特别情况下)
1 parent 3e57f52 commit 47f1cf8

File tree

4 files changed

+30
-15
lines changed

4 files changed

+30
-15
lines changed

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.16
1+
3.0.17

core/cluster.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ def get_width_storage(self, c_storage: Optional[storages.iStorage] = None) -> st
210210
current_storage.current_width += 1
211211
return current_storage
212212
else:
213+
current_storage.current_width = 0
213214
self.available_storages.remove(current_storage)
214215
self.available_storages.append(current_storage)
215216
if c_storage is not None:

core/storages/__init__.py

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -372,17 +372,12 @@ def empty():
372372
update_tqdm = update
373373

374374
files: defaultdict[str, deque[File]] = defaultdict(deque)
375-
async with aiohttp.ClientSession(
376-
self.url,
377-
headers={
378-
"Authorization": await self._get_token()
379-
}
380-
) as session:
381-
for root_id in range(0, 256):
382-
root = f"{self.path}/{root_id:02x}"
383-
if f"listfile_{root}" in self.cache:
384-
result = self.cache.get(f"listfile_{root}")
385-
else:
375+
async def get_files(root_id: int):
376+
root = f"{self.path}/{root_id:02x}"
377+
if f"listfile_{root}" in self.cache:
378+
result = self.cache.get(f"listfile_{root}")
379+
else:
380+
try:
386381
async with session.post(
387382
"/api/fs/list",
388383
data={
@@ -395,8 +390,24 @@ def empty():
395390
if result.code != 200:
396391
logger.tdebug("storage.debug.error_alist", status=result.code, message=result.message)
397392
else:
398-
self.cache.set(f"listfile_{root}", result, 30)
399-
for r in ((result.data or {}).get("content", None) or []):
393+
self.cache.set(f"listfile_{root}", result, 60)
394+
except:
395+
logger.traceback()
396+
return []
397+
return ((result.data or {}).get("content", None) or [])
398+
async with aiohttp.ClientSession(
399+
self.url,
400+
headers={
401+
"Authorization": await self._get_token()
402+
}
403+
) as session:
404+
results = await asyncio.gather(
405+
*(get_files(root_id) for root_id in range(256))
406+
)
407+
for root_id, result in zip(
408+
range(256), results
409+
):
410+
for r in result:
400411
file = File(
401412
r["name"],
402413
r["size"],

core/units.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,10 @@ def format_count_datetime(secs: float) -> str:
6666
ms = int(secs * 1000)
6767
s = int(ms / 1000) % 60
6868
m = int(ms / (1000 * 60)) % 60
69-
h = int(ms / (1000 * 60 * 60))
69+
h = int(ms / (1000 * 60 * 60)) % 24
70+
d = int(ms / (1000 * 60 * 60 * 24))
71+
if d > 0:
72+
return f'{d:02d}:{h:02d}:{m:02d}:{s:02d}'
7073
if h > 0:
7174
return f'{h:02d}:{m:02d}:{s:02d}'
7275
else:

0 commit comments

Comments
 (0)