mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-11 01:29:00 +08:00
feat: 组合订阅错误信息将包含出现错误的子订阅名称; 获取流量失败时, 不影响节点订阅; 订阅上游无有效节点时将报错
This commit is contained in:
parent
8c5dca71fb
commit
5e14d05c30
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.14.29",
|
||||
"version": "2.14.30",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
|
@ -32,10 +32,18 @@ async function downloadSubscription(req, res) {
|
||||
});
|
||||
|
||||
if (sub.source !== 'local') {
|
||||
// forward flow headers
|
||||
const flowInfo = await getFlowHeaders(sub.url);
|
||||
if (flowInfo) {
|
||||
res.set('subscription-userinfo', flowInfo);
|
||||
try {
|
||||
// forward flow headers
|
||||
const flowInfo = await getFlowHeaders(sub.url);
|
||||
if (flowInfo) {
|
||||
res.set('subscription-userinfo', flowInfo);
|
||||
}
|
||||
} catch (err) {
|
||||
$.error(
|
||||
`订阅 ${name} 获取流量信息时发生错误: ${JSON.stringify(
|
||||
err,
|
||||
)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,15 +58,15 @@ async function downloadSubscription(req, res) {
|
||||
$.notify(
|
||||
`🌍 Sub-Store 下载订阅失败`,
|
||||
`❌ 无法下载订阅:${name}!`,
|
||||
`🤔 原因:${JSON.stringify(err)}`,
|
||||
`🤔 原因:${err.message ?? err}`,
|
||||
);
|
||||
$.error(JSON.stringify(err));
|
||||
$.error(err.message ?? err);
|
||||
failed(
|
||||
res,
|
||||
new InternalServerError(
|
||||
'INTERNAL_SERVER_ERROR',
|
||||
`Failed to download subscription: ${name}`,
|
||||
`Reason: ${JSON.stringify(err)}`,
|
||||
`Reason: ${err.message ?? err}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
@ -101,9 +109,17 @@ async function downloadCollection(req, res) {
|
||||
if (subnames.length > 0) {
|
||||
const sub = findByName(allSubs, subnames[0]);
|
||||
if (sub.source !== 'local') {
|
||||
const flowInfo = await getFlowHeaders(sub.url);
|
||||
if (flowInfo) {
|
||||
res.set('subscription-userinfo', flowInfo);
|
||||
try {
|
||||
const flowInfo = await getFlowHeaders(sub.url);
|
||||
if (flowInfo) {
|
||||
res.set('subscription-userinfo', flowInfo);
|
||||
}
|
||||
} catch (err) {
|
||||
$.error(
|
||||
`组合订阅 ${name} 中的子订阅 ${
|
||||
sub.name
|
||||
} 获取流量信息时发生错误: ${err.message ?? err}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -126,7 +142,7 @@ async function downloadCollection(req, res) {
|
||||
new InternalServerError(
|
||||
'INTERNAL_SERVER_ERROR',
|
||||
`Failed to download collection: ${name}`,
|
||||
`Reason: ${JSON.stringify(err)}`,
|
||||
`Reason: ${err.message ?? err}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ async function gistBackup(req, res) {
|
||||
new InternalServerError(
|
||||
'BACKUP_FAILED',
|
||||
`Failed to ${action} data to gist!`,
|
||||
`Reason: ${JSON.stringify(err)}`,
|
||||
`Reason: ${err.message ?? err}`,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@ -42,6 +42,9 @@ async function produceArtifact({ type, name, platform }) {
|
||||
sub.process || [],
|
||||
platform,
|
||||
);
|
||||
if (proxies.length === 0) {
|
||||
throw new Error(`订阅 ${name} 中不含有效节点`);
|
||||
}
|
||||
// check duplicate
|
||||
const exist = {};
|
||||
for (const proxy of proxies) {
|
||||
@ -67,6 +70,7 @@ async function produceArtifact({ type, name, platform }) {
|
||||
const collection = findByName(allCols, name);
|
||||
const subnames = collection.subscriptions;
|
||||
const results = {};
|
||||
const errors = {};
|
||||
let processed = 0;
|
||||
|
||||
await Promise.all(
|
||||
@ -97,6 +101,7 @@ async function produceArtifact({ type, name, platform }) {
|
||||
);
|
||||
} catch (err) {
|
||||
processed++;
|
||||
errors[name] = err;
|
||||
$.error(
|
||||
`❌ 处理组合订阅中的子订阅: ${
|
||||
sub.name
|
||||
@ -108,10 +113,18 @@ async function produceArtifact({ type, name, platform }) {
|
||||
}),
|
||||
);
|
||||
|
||||
if (Object.keys(errors).length > 0) {
|
||||
throw new Error(
|
||||
`组合订阅 ${name} 中的子订阅 ${Object.keys(errors).join(
|
||||
', ',
|
||||
)} 发生错误, 请查看日志`,
|
||||
);
|
||||
}
|
||||
|
||||
// merge proxies with the original order
|
||||
let proxies = Array.prototype.concat.apply(
|
||||
[],
|
||||
subnames.map((name) => results[name]),
|
||||
subnames.map((name) => results[name] || []),
|
||||
);
|
||||
|
||||
// apply own processors
|
||||
@ -121,7 +134,7 @@ async function produceArtifact({ type, name, platform }) {
|
||||
platform,
|
||||
);
|
||||
if (proxies.length === 0) {
|
||||
throw new Error(`组合订阅中不含有效节点!`);
|
||||
throw new Error(`组合订阅 ${name} 中不含有效节点`);
|
||||
}
|
||||
// check duplicate
|
||||
const exist = {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user