Skip to content

Commit 59ea2bd

Browse files
committed
feat: 获取订阅时, 总是检查是否包含有效节点
1 parent 1c9ae2a commit 59ea2bd

2 files changed

Lines changed: 19 additions & 29 deletions

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.19.97",
3+
"version": "2.19.98",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/utils/download.js

Lines changed: 18 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -260,37 +260,27 @@ export default async function download(
260260
shouldCache = false;
261261
}
262262
}
263+
if (preprocess) {
264+
try {
265+
const proxies = ProxyUtils.parse(body);
266+
if (!Array.isArray(proxies) || proxies.length === 0) {
267+
$.error(`URL ${url} 不包含有效节点, 不缓存`);
268+
shouldCache = false;
269+
}
270+
} catch (e) {
271+
$.error(
272+
`URL ${url} 尝试解析节点失败 ${e.message ?? e}, 不缓存`,
273+
);
274+
shouldCache = false;
275+
}
276+
}
263277
if (shouldCache) {
264278
resourceCache.set(id, body);
265279
if (customCacheKey) {
266-
let shouldWriteCustomCacheKey = true;
267-
if (preprocess) {
268-
try {
269-
const proxies = ProxyUtils.parse(body);
270-
if (
271-
!Array.isArray(proxies) ||
272-
proxies.length === 0
273-
) {
274-
$.error(
275-
`URL ${url} 不包含有效节点\n不写入自定义缓存 ${$arguments?.cacheKey}`,
276-
);
277-
shouldWriteCustomCacheKey = false;
278-
}
279-
} catch (e) {
280-
$.error(
281-
`URL ${url} 尝试解析节点失败 ${
282-
e.message ?? e
283-
}\n不写入自定义缓存 ${$arguments?.cacheKey}`,
284-
);
285-
shouldWriteCustomCacheKey = false;
286-
}
287-
}
288-
if (shouldWriteCustomCacheKey) {
289-
$.info(
290-
`URL ${url}\n写入自定义缓存 ${$arguments?.cacheKey}`,
291-
);
292-
$.write(body, customCacheKey);
293-
}
280+
$.info(
281+
`URL ${url}\n写入自定义缓存 ${$arguments?.cacheKey}`,
282+
);
283+
$.write(body, customCacheKey);
294284
}
295285
}
296286

0 commit comments

Comments
 (0)