Skip to content

Commit 4ed626c

Browse files
committed
fix: 修复没有测速文件的问题
1 parent 457dff7 commit 4ed626c

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

core/cluster.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ async def _fetch_cluster_name(self):
711711
def hit(self, cluster_id: str, bytes: int):
712712
self._clusters[cluster_id].counter.hits += 1
713713
self._clusters[cluster_id].counter.bytes += bytes
714-
714+
715715
async def get_response_file(self, hash: str) -> ResponseFile:
716716
storage = self.storages.get_weight_storage()
717717
if storage is None:
@@ -726,14 +726,17 @@ async def get_response_file(self, hash: str) -> ResponseFile:
726726
0
727727
)
728728

729-
async def get_measure_file(self, size: int) -> ResponseFile:
729+
async def get_measure_file(self, size: int) -> Optional[ResponseFile]:
730730
if not self.storages._online_storages:
731731
logger.twarning("cluster.get_measure_file.no_storage")
732732
return ResponseFile(
733733
0
734734
)
735735
storage = self.storages._online_storages[0]
736-
return await storage.get_file(f"measure/{size}")
736+
try:
737+
return await storage.get_file(f"measure/{size}")
738+
except:
739+
return None
737740

738741

739742
if cfg.concurrency_enable_cluster:

core/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def concurrency_enable_cluster(self) -> bool:
9292

9393

9494
API_VERSION = "1.13.1"
95-
VERSION = "4.0.10"
95+
VERSION = "4.0.11"
9696
PROJECT = "PythonOpenBMCLAPI"
9797
USER_AGENT = f"openbmclapi-cluster/{API_VERSION} {PROJECT}/{VERSION}"
9898
ROOT_PATH = Path(__file__).parent.parent

core/storage/abc.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,21 @@ def path(self) -> 'CPath':
121121
return self._path
122122

123123

124+
async def write_measure(self, size: int):
125+
path = f"measure/{size}"
126+
file = await self.get_file(path)
127+
size = size * 1024 * 1024
128+
if isinstance(file, (ResponseFileRemote, ResponseFileMemory, ResponseFileLocal)) and file.size == size:
129+
return
130+
131+
tmp = tempfile.TemporaryFile()
132+
tmp.write(b'\x00' * size)
133+
await self.upload(
134+
path,
135+
tmp,
136+
size
137+
)
138+
124139
def get_py_check_path(self) -> 'CPath':
125140
return self.path / ".py_check"
126141

requirements.txt

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)