Skip to content

Commit

Permalink
feat: 订阅刷新按钮逻辑调整为无缓存刷新订阅和流量
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Nov 9, 2024
1 parent 772f431 commit cc58a55
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
11 changes: 11 additions & 0 deletions backend/src/restful/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ async function downloadSubscription(req, res) {
includeUnsupportedProxy,
resultFormat,
proxy,
noCache,
} = req.query;
let $options = {};
if (req.query.$options) {
Expand Down Expand Up @@ -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) {
Expand All @@ -151,6 +156,7 @@ async function downloadSubscription(req, res) {
},
$options,
proxy,
noCache,
});

if (
Expand Down Expand Up @@ -283,6 +289,7 @@ async function downloadCollection(req, res) {
includeUnsupportedProxy,
resultFormat,
proxy,
noCache,
} = req.query;

let $options = {};
Expand Down Expand Up @@ -325,6 +332,9 @@ async function downloadCollection(req, res) {
if (useMihomoExternal) {
$.info(`手动指定了 target 为 SurgeMac, 将使用 Mihomo External`);
}
if (noCache) {
$.info(`指定不使用缓存: ${noCache}`);
}

if (collection) {
try {
Expand All @@ -340,6 +350,7 @@ async function downloadCollection(req, res) {
},
$options,
proxy,
noCache,
});

// forward flow header from the first subscription in this collection
Expand Down
12 changes: 12 additions & 0 deletions backend/src/restful/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ async function produceArtifact({
awaitCustomCache,
$options,
proxy,
noCache,
}) {
platform = platform || 'JSON';

Expand Down Expand Up @@ -72,6 +73,7 @@ async function produceArtifact({
proxy || sub.proxy,
undefined,
awaitCustomCache,
noCache,
);
} catch (err) {
errors[url] = err;
Expand Down Expand Up @@ -119,6 +121,7 @@ async function produceArtifact({
proxy || sub.proxy,
undefined,
awaitCustomCache,
noCache,
);
} catch (err) {
errors[url] = err;
Expand Down Expand Up @@ -237,6 +240,9 @@ async function produceArtifact({
proxy ||
sub.proxy ||
collection.proxy,
undefined,
undefined,
noCache,
);
} catch (err) {
errors[url] = err;
Expand Down Expand Up @@ -410,6 +416,9 @@ async function produceArtifact({
ua || file.ua,
undefined,
file.proxy || proxy,
undefined,
undefined,
noCache,
);
} catch (err) {
errors[url] = err;
Expand Down Expand Up @@ -458,6 +467,9 @@ async function produceArtifact({
ua || file.ua,
undefined,
file.proxy || proxy,
undefined,
undefined,
noCache,
);
} catch (err) {
errors[url] = err;
Expand Down
5 changes: 3 additions & 2 deletions backend/src/utils/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default async function download(
customProxy,
skipCustomCache,
awaitCustomCache,
noCache,
) {
let $arguments = {};
let url = rawUrl.replace(/#noFlow$/, '');
Expand Down Expand Up @@ -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使用常规缓存以避免重复请求`,
);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit cc58a55

Please sign in to comment.