Skip to content

Commit 2cd30df

Browse files
committed
feat: 内容无变化时 不进行上传; 增加 gist 数量日志
1 parent d53947d commit 2cd30df

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sub-store",
3-
"version": "2.16.55",
3+
"version": "2.16.56",
44
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and Shadowrocket.",
55
"main": "src/main.js",
66
"scripts": {

backend/src/restful/miscs.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,21 @@ async function gistBackupAction(action) {
109109
const updated = settings.syncTime;
110110
switch (action) {
111111
case 'upload':
112+
try {
113+
content = $.read('#sub-store');
114+
if ($.env.isNode) content = JSON.stringify($.cache, null, ` `);
115+
$.info(`下载备份, 与本地内容对比...`);
116+
const onlineContent = await gist.download(
117+
GIST_BACKUP_FILE_NAME,
118+
);
119+
if (onlineContent === content) {
120+
$.info(`内容一致, 无需上传备份`);
121+
return;
122+
}
123+
} catch (error) {
124+
$.error(`${error.message ?? error}`);
125+
}
126+
112127
// update syncTime
113128
settings.syncTime = new Date().getTime();
114129
$.write(settings, SETTINGS_KEY);

backend/src/utils/gist.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export default class Gist {
118118
.get('/gists?per_page=100&page=1')
119119
.then((response) => {
120120
const gists = JSON.parse(response.body);
121+
$.info(`获取到当前 GitHub 用户的 gist: ${gists.length} 个`);
121122
for (let g of gists) {
122123
if (g.description === this.key) {
123124
return g;

0 commit comments

Comments
 (0)