Compare commits

...

3 Commits

Author SHA1 Message Date
Cp0204
f1cf1f0eb8 🐛 修复请求错误处理逻辑
Some checks are pending
Docker Publish / build-and-push (push) Waiting to run
- 注释掉 `response.raise_for_status()` 以避免非200状态码抛出异常
- 修改错误响应内容
2024-12-05 16:51:38 +08:00
Cp0204
c90262485f 🐛 添加 shareurl 解码的错误处理
- 添加try-catch块以处理decodeURIComponent函数中的潜在错误
2024-12-05 16:50:26 +08:00
Cp0204
7d8701db0a 🐛 修复任务查询报错
- 一处 `_send_request()` 方法漏改
2024-12-05 11:24:07 +08:00
2 changed files with 13 additions and 7 deletions

View File

@ -524,11 +524,16 @@
changeShareurl(task) {
if (!task.shareurl)
return;
this.$set(task, "shareurl_ban", undefined);
// 从URL中提取任务名
const matches = decodeURIComponent(task.shareurl).match(/\/(\w{32})-([^\/]+)$/);
if (matches) {
task.taskname = task.taskname == "" ? matches[2] : task.taskname;
task.savepath = task.savepath.replace(/TASKNAME/g, matches[2]);
try {
const matches = decodeURIComponent(task.shareurl).match(/\/(\w{32})-([^\/]+)$/);
if (matches) {
task.taskname = task.taskname == "" ? matches[2] : task.taskname;
task.savepath = task.savepath.replace(/TASKNAME/g, matches[2]);
}
} catch (e) {
console.error("Error decodeURIComponent:", e);
}
// 从分享中提取任务名
axios.get('/get_share_detail', { params: { shareurl: task.shareurl } })

View File

@ -185,13 +185,13 @@ class Quark:
try:
response = requests.request(method, url, headers=headers, **kwargs)
# print(f"{response.text}")
response.raise_for_status() # 检查请求是否成功
# response.raise_for_status() # 检查请求是否成功但返回非200也会抛出异常
return response
except Exception as e:
print(f"_send_request error:\n{e}")
fake_response = requests.Response()
fake_response.status_code = 500
fake_response._content = b'{"error": 1}'
fake_response._content = b'{"status": 500, "message": "request error"}'
return fake_response
def init(self):
@ -263,6 +263,7 @@ class Quark:
response = self._send_request(
"POST", url, json=payload, params=querystring
).json()
print(response)
if response.get("status") == 200:
return True, response["data"]["stoken"]
else:
@ -381,7 +382,7 @@ class Quark:
"__dt": int(random.uniform(1, 5) * 60 * 1000),
"__t": datetime.now().timestamp(),
}
response = requests.request("GET", url, params=querystring).json()
response = self._send_request("GET", url, params=querystring).json()
if response["data"]["status"] != 0:
if retry_index > 0:
print()