fix: 处理手动删除 Gist 之后, Sub-Store 侧重新同步的逻辑

This commit is contained in:
xream 2024-04-23 09:28:39 +08:00
parent 6f7fe8204b
commit 2586c29746
No known key found for this signature in database
GPG Key ID: 1D2C5225471789F9
3 changed files with 23 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "sub-store", "name": "sub-store",
"version": "2.14.298", "version": "2.14.299",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js", "main": "src/main.js",
"scripts": { "scripts": {

View File

@ -253,7 +253,25 @@ async function syncToGist(files) {
key: ARTIFACT_REPOSITORY_KEY, key: ARTIFACT_REPOSITORY_KEY,
syncPlatform, syncPlatform,
}); });
return manager.upload(files); const res = await manager.upload(files);
let body = {};
try {
body = JSON.parse(res.body);
// eslint-disable-next-line no-empty
} catch (e) {}
const url = body?.html_url ?? body?.web_url;
const settings = $.read(SETTINGS_KEY);
if (url) {
$.log(`同步 Gist 后, 找到 Sub-Store Gist: ${url}`);
settings.artifactStore = url;
settings.artifactStoreStatus = 'VALID';
} else {
$.error(`同步 Gist 后, 找不到 Sub-Store Gist`);
settings.artifactStoreStatus = 'NOT FOUND';
}
$.write(settings, SETTINGS_KEY);
return res;
} }
export { syncToGist }; export { syncToGist };

View File

@ -135,9 +135,9 @@ export default class Gist {
} }
} }
}); });
console.log(`result`, result); // console.log(`result`, result);
console.log(`files`, files); // console.log(`files`, files);
console.log(`actions`, actions); // console.log(`actions`, actions);
if (this.syncPlatform === 'gitlab') { if (this.syncPlatform === 'gitlab') {
if (Object.keys(result).length === 0) { if (Object.keys(result).length === 0) {