From cc58a5541ed186dcf89ebb7151cd68756ea43159 Mon Sep 17 00:00:00 2001 From: xream Date: Sun, 10 Nov 2024 01:22:48 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=AE=A2=E9=98=85=E5=88=B7=E6=96=B0?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E9=80=BB=E8=BE=91=E8=B0=83=E6=95=B4=E4=B8=BA?= =?UTF-8?q?=E6=97=A0=E7=BC=93=E5=AD=98=E5=88=B7=E6=96=B0=E8=AE=A2=E9=98=85?= =?UTF-8?q?=E5=92=8C=E6=B5=81=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/package.json | 2 +- backend/src/restful/download.js | 11 +++++++++++ backend/src/restful/sync.js | 12 ++++++++++++ backend/src/utils/download.js | 5 +++-- 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/backend/package.json b/backend/package.json index d338e94c1..06e8fccbd 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,6 +1,6 @@ { "name": "sub-store", - "version": "2.14.414", + "version": "2.14.415", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "main": "src/main.js", "scripts": { diff --git a/backend/src/restful/download.js b/backend/src/restful/download.js index 8664170b7..168ed32d1 100644 --- a/backend/src/restful/download.js +++ b/backend/src/restful/download.js @@ -75,6 +75,7 @@ async function downloadSubscription(req, res) { includeUnsupportedProxy, resultFormat, proxy, + noCache, } = req.query; let $options = {}; if (req.query.$options) { @@ -131,6 +132,10 @@ async function downloadSubscription(req, res) { $.info(`手动指定了 target 为 SurgeMac, 将使用 Mihomo External`); } + if (noCache) { + $.info(`指定不使用缓存: ${noCache}`); + } + const allSubs = $.read(SUBS_KEY); const sub = findByName(allSubs, name); if (sub) { @@ -151,6 +156,7 @@ async function downloadSubscription(req, res) { }, $options, proxy, + noCache, }); if ( @@ -283,6 +289,7 @@ async function downloadCollection(req, res) { includeUnsupportedProxy, resultFormat, proxy, + noCache, } = req.query; let $options = {}; @@ -325,6 +332,9 @@ async function downloadCollection(req, res) { if (useMihomoExternal) { $.info(`手动指定了 target 为 SurgeMac, 将使用 Mihomo External`); } + if (noCache) { + $.info(`指定不使用缓存: ${noCache}`); + } if (collection) { try { @@ -340,6 +350,7 @@ async function downloadCollection(req, res) { }, $options, proxy, + noCache, }); // forward flow header from the first subscription in this collection diff --git a/backend/src/restful/sync.js b/backend/src/restful/sync.js index b28057aa7..d1d193bda 100644 --- a/backend/src/restful/sync.js +++ b/backend/src/restful/sync.js @@ -39,6 +39,7 @@ async function produceArtifact({ awaitCustomCache, $options, proxy, + noCache, }) { platform = platform || 'JSON'; @@ -72,6 +73,7 @@ async function produceArtifact({ proxy || sub.proxy, undefined, awaitCustomCache, + noCache, ); } catch (err) { errors[url] = err; @@ -119,6 +121,7 @@ async function produceArtifact({ proxy || sub.proxy, undefined, awaitCustomCache, + noCache, ); } catch (err) { errors[url] = err; @@ -237,6 +240,9 @@ async function produceArtifact({ proxy || sub.proxy || collection.proxy, + undefined, + undefined, + noCache, ); } catch (err) { errors[url] = err; @@ -410,6 +416,9 @@ async function produceArtifact({ ua || file.ua, undefined, file.proxy || proxy, + undefined, + undefined, + noCache, ); } catch (err) { errors[url] = err; @@ -458,6 +467,9 @@ async function produceArtifact({ ua || file.ua, undefined, file.proxy || proxy, + undefined, + undefined, + noCache, ); } catch (err) { errors[url] = err; diff --git a/backend/src/utils/download.js b/backend/src/utils/download.js index 74980a7a6..c0c8d1ed5 100644 --- a/backend/src/utils/download.js +++ b/backend/src/utils/download.js @@ -21,6 +21,7 @@ export default async function download( customProxy, skipCustomCache, awaitCustomCache, + noCache, ) { let $arguments = {}; let url = rawUrl.replace(/#noFlow$/, ''); @@ -65,7 +66,7 @@ export default async function download( if (customCacheKey && !skipCustomCache) { const customCached = $.read(customCacheKey); const cached = resourceCache.get(id); - if (!$arguments?.noCache && cached) { + if (!noCache && !$arguments?.noCache && cached) { $.info( `乐观缓存: URL ${url}\n存在有效的常规缓存\n使用常规缓存以避免重复请求`, ); @@ -149,7 +150,7 @@ export default async function download( // try to find in app cache const cached = resourceCache.get(id); - if (!$arguments?.noCache && cached) { + if (!noCache && !$arguments?.noCache && cached) { $.info(`使用缓存: ${url}`); result = cached; if (customCacheKey) {