Skip to content

Commit

Permalink
fix: 缓存不合法时即刻重置
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Feb 6, 2024
1 parent 36377f3 commit df0ac8a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 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.211",
"version": "2.14.212",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
12 changes: 11 additions & 1 deletion backend/src/utils/headers-resource-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ class ResourceCache {
if (!$.read(HEADERS_RESOURCE_CACHE_KEY)) {
$.write('{}', HEADERS_RESOURCE_CACHE_KEY);
}
this.resourceCache = JSON.parse($.read(HEADERS_RESOURCE_CACHE_KEY));
try {
this.resourceCache = JSON.parse($.read(HEADERS_RESOURCE_CACHE_KEY));
} catch (e) {
$.error(
`解析持久化缓存中的 ${HEADERS_RESOURCE_CACHE_KEY} 失败, 重置为 {}, 错误: ${
e?.message ?? e
}`,
);
this.resourceCache = {};
$.write('{}', HEADERS_RESOURCE_CACHE_KEY);
}
this._cleanup();
}

Expand Down
12 changes: 11 additions & 1 deletion backend/src/utils/resource-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@ class ResourceCache {
if (!$.read(RESOURCE_CACHE_KEY)) {
$.write('{}', RESOURCE_CACHE_KEY);
}
this.resourceCache = JSON.parse($.read(RESOURCE_CACHE_KEY));
try {
this.resourceCache = JSON.parse($.read(RESOURCE_CACHE_KEY));
} catch (e) {
$.error(
`解析持久化缓存中的 ${RESOURCE_CACHE_KEY} 失败, 重置为 {}, 错误: ${
e?.message ?? e
}`,
);
this.resourceCache = {};
$.write('{}', RESOURCE_CACHE_KEY);
}
this._cleanup();
}

Expand Down
12 changes: 11 additions & 1 deletion backend/src/utils/script-resource-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ class ResourceCache {
if (!$.read(SCRIPT_RESOURCE_CACHE_KEY)) {
$.write('{}', SCRIPT_RESOURCE_CACHE_KEY);
}
this.resourceCache = JSON.parse($.read(SCRIPT_RESOURCE_CACHE_KEY));
try {
this.resourceCache = JSON.parse($.read(SCRIPT_RESOURCE_CACHE_KEY));
} catch (e) {
$.error(
`解析持久化缓存中的 ${SCRIPT_RESOURCE_CACHE_KEY} 失败, 重置为 {}, 错误: ${
e?.message ?? e
}`,
);
this.resourceCache = {};
$.write('{}', SCRIPT_RESOURCE_CACHE_KEY);
}
this._cleanup();
}

Expand Down

0 comments on commit df0ac8a

Please sign in to comment.