Compare commits

...

1 Commits

Author SHA1 Message Date
xream
59ea2bd174 feat: 获取订阅时, 总是检查是否包含有效节点 2025-07-29 11:59:55 +08:00
2 changed files with 19 additions and 29 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "sub-store",
"version": "2.19.97",
"version": "2.19.98",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {

View File

@@ -260,37 +260,27 @@ export default async function download(
shouldCache = false;
}
}
if (preprocess) {
try {
const proxies = ProxyUtils.parse(body);
if (!Array.isArray(proxies) || proxies.length === 0) {
$.error(`URL ${url} 不包含有效节点, 不缓存`);
shouldCache = false;
}
} catch (e) {
$.error(
`URL ${url} 尝试解析节点失败 ${e.message ?? e}, 不缓存`,
);
shouldCache = false;
}
}
if (shouldCache) {
resourceCache.set(id, body);
if (customCacheKey) {
let shouldWriteCustomCacheKey = true;
if (preprocess) {
try {
const proxies = ProxyUtils.parse(body);
if (
!Array.isArray(proxies) ||
proxies.length === 0
) {
$.error(
`URL ${url} 不包含有效节点\n不写入自定义缓存 ${$arguments?.cacheKey}`,
);
shouldWriteCustomCacheKey = false;
}
} catch (e) {
$.error(
`URL ${url} 尝试解析节点失败 ${
e.message ?? e
}\n不写入自定义缓存 ${$arguments?.cacheKey}`,
);
shouldWriteCustomCacheKey = false;
}
}
if (shouldWriteCustomCacheKey) {
$.info(
`URL ${url}\n写入自定义缓存 ${$arguments?.cacheKey}`,
);
$.write(body, customCacheKey);
}
$.info(
`URL ${url}\n写入自定义缓存 ${$arguments?.cacheKey}`,
);
$.write(body, customCacheKey);
}
}