From 59ea2bd174e199860c303d408d09341b4391d4ba Mon Sep 17 00:00:00 2001 From: xream Date: Tue, 29 Jul 2025 11:59:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8E=B7=E5=8F=96=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E6=97=B6,=20=E6=80=BB=E6=98=AF=E6=A3=80=E6=9F=A5=E6=98=AF?= =?UTF-8?q?=E5=90=A6=E5=8C=85=E5=90=AB=E6=9C=89=E6=95=88=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/utils/download.js | 46 ++++++++++++++--------------------- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/backend/package.json b/backend/package.json index 64712fc..33e1916 100644 --- a/backend/package.json +++ b/backend/package.json @@ -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": { diff --git a/backend/src/utils/download.js b/backend/src/utils/download.js index a5add40..f614a38 100644 --- a/backend/src/utils/download.js +++ b/backend/src/utils/download.js @@ -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); } }