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