Skip to content

Commit

Permalink
feat: 内容无变化时 不进行上传; 增加 gist 数量日志
Browse files Browse the repository at this point in the history
  • Loading branch information
xream committed Feb 26, 2025
1 parent d53947d commit 2cd30df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
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.16.55",
"version": "2.16.56",
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
"main": "src/main.js",
"scripts": {
Expand Down
15 changes: 15 additions & 0 deletions backend/src/restful/miscs.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,21 @@ async function gistBackupAction(action) {
const updated = settings.syncTime;
switch (action) {
case 'upload':
try {
content = $.read('#sub-store');
if ($.env.isNode) content = JSON.stringify($.cache, null, ` `);
$.info(`下载备份, 与本地内容对比...`);
const onlineContent = await gist.download(
GIST_BACKUP_FILE_NAME,
);
if (onlineContent === content) {
$.info(`内容一致, 无需上传备份`);
return;
}
} catch (error) {
$.error(`${error.message ?? error}`);
}

// update syncTime
settings.syncTime = new Date().getTime();
$.write(settings, SETTINGS_KEY);
Expand Down
1 change: 1 addition & 0 deletions backend/src/utils/gist.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ export default class Gist {
.get('/gists?per_page=100&page=1')
.then((response) => {
const gists = JSON.parse(response.body);
$.info(`获取到当前 GitHub 用户的 gist: ${gists.length} 个`);
for (let g of gists) {
if (g.description === this.key) {
return g;
Expand Down

0 comments on commit 2cd30df

Please sign in to comment.