Skip to content

Commit

Permalink
fix: 处理手动删除 Gist 之后, Sub-Store 侧重新同步的逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Apr 23, 2024
1 parent 6f7fe82 commit 2586c29
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 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.298",
"version": "2.14.299",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
"main": "src/main.js",
"scripts": {
Expand Down
20 changes: 19 additions & 1 deletion backend/src/restful/artifacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,25 @@ async function syncToGist(files) {
key: ARTIFACT_REPOSITORY_KEY,
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 };
6 changes: 3 additions & 3 deletions backend/src/utils/gist.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ export default class Gist {
}
}
});
console.log(`result`, result);
console.log(`files`, files);
console.log(`actions`, actions);
// console.log(`result`, result);
// console.log(`files`, files);
// console.log(`actions`, actions);

if (this.syncPlatform === 'gitlab') {
if (Object.keys(result).length === 0) {
Expand Down

0 comments on commit 2586c29

Please sign in to comment.