Skip to content

Commit

Permalink
fix: 修复有时候调用 /download 接口 500 的问题;面板的显示存储时间不正常的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
tianxiu2b2t committed Dec 12, 2024
1 parent 51556c0 commit 4a56922
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
13 changes: 11 additions & 2 deletions assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1224,9 +1224,18 @@ async function load() {
)
} else {
var server_time = $dashboard_locals.info_runtime
var latest_time = (() => {
const data = value;
const keys = Object.keys(data);
const res = [];
for (let i = 0; i < keys.length; i++) {
res.push(+new Date(keys[i] + "T00:00:00.000Z"));
}
return Math.max(...res);
})();
// object.current_time - object.start_time - object.diff / 1000.0 + (+new Date() - object.resp_timestamp) / 1000.0;
var time = server_time.start_time - server_time.diff / 1000.0 + (+new Date() - server_time.resp_timestamp) / 1000.0;
const previous = (time - (time % (24 * 3600)) - 86400 * 30);
var time = server_time.current_time - server_time.diff / 1000.0 + (+new Date() - server_time.resp_timestamp) / 1000.0;
const previous = (time + (time % (24 * 3600)) - 86400 * 30);
const res = {}
for (let i = 0; i < 30; i++) {
var d = Tools.formatDate(new Date((previous + i * 86400) * 1000.0))
Expand Down
12 changes: 8 additions & 4 deletions core/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ async def get_file(self, hash: str, use_master: bool = False):
if await self.available() and not use_master:
storage = self.get_width_storage()
if isinstance(storage, storages.LocalStorage) and await storage.exists(hash):
return LocalStorageFile(
file = LocalStorageFile(
hash,
await storage.get_size(hash),
await storage.get_mtime(hash),
storage,
Path(storage.get_path(hash))
)
elif isinstance(storage, storages.AlistStorage):
return URLStorageFile(
file = URLStorageFile(
hash,
await storage.get_size(hash),
await storage.get_mtime(hash),
Expand All @@ -200,20 +200,24 @@ async def get_file(self, hash: str, use_master: bool = False):
hash
)
if storage_file.data_size() == 0 and storage_file.url:
return URLStorageFile(
file = URLStorageFile(
hash,
await storage.get_size(hash),
await storage.get_mtime(hash),
storage,
storage_file.url
)
if storage_file.data_size() > 0:
return MemoryStorageFile(
file = MemoryStorageFile(
hash,
await storage.get_size(hash),
await storage.get_mtime(hash),
storage_file.data.getvalue()
)
if isinstance(file, URLStorageFile) and not file.url:
file = None
if file is not None:
return file
async with aiohttp.ClientSession(
config.const.base_url,
) as session:
Expand Down
2 changes: 1 addition & 1 deletion core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def rank_clusters_url(self):

const = Const()

VERSION = "3.3.6"
VERSION = "3.3.7"
API_VERSION = "1.13.1"
USER_AGENT = f"openbmclapi/{API_VERSION} python-openbmclapi/{VERSION}"
PYTHON_VERSION = ".".join(map(str, (sys.version_info.major, sys.version_info.minor, sys.version_info.micro)))
6 changes: 3 additions & 3 deletions core/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ async def init():

scheduler.run_repeat_later(
check_server,
60,
10
5,
5
)

async def forward_data(reader: asyncio.StreamReader, writer: asyncio.StreamWriter):
Expand Down Expand Up @@ -409,7 +409,7 @@ async def _check_server(
)
w.close()
try:
await asyncio.wait_for(w.wait_closed(), timeout=10)
await asyncio.wait_for(w.wait_closed(), timeout=2)
except:
...
return True
Expand Down

0 comments on commit 4a56922

Please sign in to comment.